User Manual - screen and tmux

Many times you will find yourself wanting to start a long running process on one of our servers and later realize that you'd rather not keep your client machine turned on and connected the entire time to allow said process to finish executing. Here is a quick guide on how to solve this problem and allow you to disconnect your client machine entirely without interrupting the execution of your processes.

There are two different applications installed on our servers which both accomplish this goal. One is GNU screen and the other is tmux. I will cover using both, although they are in fact quite similar to one another (intentionally so!). Both programs use a control key sequence followed by a command. This will be notated on this page as:

(C-a d)

which means to first depress the Control key followed by the letter a and then let go of both, and then subsequently depress the letter d and then let go.

Also, if you're attempting to run processes which normally have both a graphical and command line component (and each can be started using the same command - matlab for example), you will probably need to make sure you have issued the command:

unset DISPLAY

in your terminal window before trying to do anything. This will make sure that the command doesn't try to start the graphical interface to the program.

screen

To get started using screen, simply type:

screen

inside a running terminal. This will display the license and copyright information and ask you to press the space or return key to continue. Once you do so, you'll simply be back at your normal terminal prompt. You can proceed by running whatever processes you want to run at this point which might take a long time to finish executing. The single most important command to know at this point is:

(C-a d)

which will detach from the running screen session and take you back to your original terminal. When you do this, any processes you left running inside of the screen session will continue running without interruption. To attach to the same session again, simply type:

screen -R

That's pretty much it! You might use the occasional:

screen -list

to make sure you don't have any screen sessions running already before starting a new one. You can even do:

(C-a ?)

to see the online help inside of a running screen session. There is a lot more you can do with screen, but this covers the most basic usage. Refer to the web site above for the full documentation or type man screen in your terminal window for more details.

tmux

To get started using tmux, simply type:

tmux

inside a running terminal. This will put you inside a newly created tmux session with a status bar along the bottom and a terminal prompt to continue issuing new commands. You can proceed by running whatever processes you want to run at this point which might take a long time to finish executing. The single most important command to know at this point is:

(C-b d)

which will detach from the running tmux session and take you back to your original terminal. When you do this, any processes you left running inside of the tmux session will continue running without interruption. To attach to the same session again, simply type:

tmux a

That's pretty much it! You might use the occasional:

tmux ls

to make sure you don't have any tmux sessions running already before starting a new one. You can even do:

(C-b ?)

to see the online help inside of a running tmux session (depress the letter q to get out of the help screen). There is a lot more you can do with tmux, but this covers the most basic usage. Refer to the web site above for the full documentation or type man tmux in your terminal window for more details.

Taxonomy upgrade extras: