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: screen and tmux. 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
.