From UABgrid Documentation
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.
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
- Oops, the IT guys 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:
ssh BlazerId@cheaha.uabgrid.uab.edu screen -S qloginjob qlogin -l h_rt=24:00:00,vf=128M wget --no-check-certificate https://some.data.site.org/impute/1000GP_Phase3.tgz
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 (number.name):
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.
- Screen tutorial: http://www.linux.com/learn/tutorials/285795-taking-command-of-the-terminal-with-gnu-screen-
- Tmux tutorial: https://danielmiessler.com/study/tmux/
- The screen user manual: http://www.gnu.org/software/screen/manual/screen.html
- The tmux user manual: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/tmux.1?query=tmux&sec=1
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.