3

When I play mulit-player Minecraft, with my family, I use an external server. Everyone once in a while the session drops in my local PC. I can re-open a new terminal and log back into the server. I can use ps aux|grep minecraft to see that the original process is still running, but I cannot see the activity or enter commands. Is there anyway I can join that running process?

What I am saying is that when I had the terminal session open and started Minecraft (MC), I could enter commands into the MC server like /list to see users, /weather clear to stop rain, etc.. etc..
When I lost the connection and logged back in I cannot see the activities going on in the server window. I can see the process is still running, but what I wanted to do was to be able to join the process as before, and enter MC commands again.

Phil
  • 31
  • 1
    maybe you are looking for something like screen or tmux – Dimitri Podborski Apr 09 '16 at 19:38
  • 1
    or try reptyr – A.B. Apr 09 '16 at 19:39
  • I use screen as soon as I login to the server, so I can open multiple xterm sessions. One xterm is used to launch the server and will show the minecraft server activity, a second xterm I use for htop and dstat to monitor for bottlenecks. However, when I relog those screen sessions are not available. I use Ctrl-A 0 and Ctrl-A 1 to see them but they don't work upon a relog. – Phil Apr 09 '16 at 19:41
  • 2
  • @cmks They said Ctrl+A doesn't work. I'm not sure why that would be the case but @ Phil, could you clarify what happens when you try to reattach to the screen session? Please [edit] that information into your question, along with the information you provided with your last comment. – kos Apr 10 '16 at 02:10
  • I don't know how exactly you are connected. For me terminal session breaks if there is no activity for a certain amount of time. In that case I run top which refreshes the screen continuously and makes sure there is traffic preventing the terminal session to break. If you run minecraft in foreground and you cannot run the top command, you can press Ctrl-Z and then type bg to run the interrupted application in background. Then you can start top. – nobody Apr 10 '16 at 08:18
  • Some more information. I am running Putty (from a windows machine) to login to our Minecraft server. When I say the session drops, I mean the putty session drops. So I have to relog in via Putty. When I log back in and try CTRL-A 0 or CTRL-A 1 to return to the sessions I was running before, it does not work. It behaves just like it should behave when someone types a 0 or 1 into a command line. – Phil Apr 10 '16 at 20:47
  • @Phil you have to start screen for Ctrl-A shortcuts to work. Did you? – muru Apr 12 '16 at 09:40
  • If I run top or CTRL-Z I cannot enter commands into the Minecraft server command line. – Phil Apr 16 '16 at 07:24
  • If I run top or CTRL-Z I cannot enter commands into the Minecraft server command line. Also to answer @cmks - when I try Ctrl+A and 0 or 1 , to return that those sessions, it says 0: command not found or 1: command not found – Phil Apr 16 '16 at 07:30
  • This question shouldn't have been closed. I think that what he is asking is very clear to me. – Nic Szerman Aug 09 '18 at 16:35

1 Answers1

5

GNU Screen is a tool that lets you reattach to a previous session. Just install it on your remote server.

apt-get install screen

Now when you connect to the machine via SSH, just type screen and press Space. You will be back to your normal terminal. Run whatever you want (minecraft) here.

Now assume your connection dropped. Buy don't worry, because it is still running in the screen session you created before. All you have to do is to re-SSH and the attach to the already running screen session. You can get a list of running sessions by:

screen -ls

From the list, choose the session you want to connect to and type:

screen -r <session-name>

And you are back!

This is one of the many awesome things you can do with screen. I have written only the minimal usage information required to achieve what the OP wanted. Here is a good tutorial if you are interested.

To exit the screen session, just type exit.

muru
  • 197,895
  • 55
  • 485
  • 740
daltonfury42
  • 5,499