Personal tools


From UABgrid Documentation

Revision as of 11:38, 20 February 2015 by (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If you are experiencing disconnects with the Cheaha head node or you want to maintain a shell context over time, then the screen or tmux commands may be helpful.

You can use either Screen or Tmux to create shell sessions on the head node (or other Linux systems) that can be disconnected without terminating the shell. They both do the same thing but have different syntax and command keys, so pick one and learn to use it.

Screen Example

A short example of why this is useful:

  • You login to cheaha from your UAB workstation to start a qlogin job:
  • Start up an interactive job using qlogin to download a large dataset that will take approximately 24 hours to complete:
qlogin -l h_rt=24:00:00,vf=128M
wget --no-check-certificate
  • Oops, the IT folks just updated your workstation with security patches that require it to reboot. Rebooting means closing the connection to Cheaha, killing your qlogin interactive job

So, how would screen or tmux solve this? If we'd have started a screen session before running the qlogin command, the job would have continued to run because screen keeps the shell alive even if our ssh connection to cheaha is disconnected. Here's how to do it:

screen -S qloginjob
qlogin -l h_rt=24:00:00,vf=128M
wget --no-check-certificate

Now that the job is running, you can disconnect from the screen session by pressing "Ctrl+a d", that's press the control and a keys together, let go, press d. Ctrl+a puts screen into command mode, the next key press will execute a screen command. In this case, the d key sends the detach command.

To reconnect to the screen, first run the following command to view active screens:

screen -ls

There is a screen on:
    28618.1000GP_Phase3    (Detached)
1 Socket in /var/run/screen/S-mhanby.

Reattach to the screen session using the full ID (

screen -r 28618.1000GP_Phase3

Or use the -d -r arguments together to force detach another connection (say you are attaching to the screen session at home and didn't detach on your UAB workstation)

screen -d -r 28618.1000GP_Phase3

You now have a screen session running on the head node that will keep the interactive job running, even if you disconnect.

There's so much more that can be done with screen and tmux. See the references below for useful information and tutorials.

Useful References

Note that if you are using X window tunneling with your qlogin session this won't work without extra manual effort for a qlogin session within screen.

This page is a stub, please help expand it.