2

I have a question your you guys. I'm running a MC server so far so great. In order to make it autonomous I run it at boot with a bash script load in rc.local, simple.

#!/bin/bash
cd /home/minecraft sudo java -Xms512M -Xmx1008M -jar /home/minecraft/spigot-1.9.jar nogui

Ok, the problem is that when i connect through ssh, i cannot see the server. It is running, because i can play with no problems, but i cannot gain control over it.

When I run the server with the comand from the script, but no at boot, the server keeps on screen, waiting for commands, and showing information, but when run it from the boot script, i cannot see anything.

How can i gain control, or see the server screen if i run it from boot and connect through ssh later?

I hope you understand what i mean. Thanks you in advance, and have a nice day.

3

The console output for most things started in the rc scripts is unavailable to you unless you attach to the physical console for your device. The same would be true if you started the MC server by hand and then logged out. You could log the output to a file, but that doesn't help you type commands into it later. Two tools are available to work around this issue: and . Either will hold onto the input and output handles for your process and let you reattach to them later. screen has been around forever but was not designed for automation. tmux is newer and not as well known, but it is much easier to automate so I'll demonstrate that:

tmux new-session -s demo -n tab_name -d "sudo top"

Will start a new tmux session named demo with one tab in it named tab_name running sudo top. When you run this control returns to the shell and you won't see the top immediately. This is good because it means you can put it in your rc scripts and it won't stop them in their tracks. Then whenever you want to get to it simply:

tmux attach

as the same user you started things with and you will have access to the input and output of the command. To escape tmux press ctrl-b, d which will take you back to your shell outside of tmux.

This is an intro you might find a good next step in learning tmux.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy