Screen

From Cheaha
Revision as of 16:38, 20 February 2015 by Mhanby@uab.edu (talk | contribs) (→‎Screen Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Attention: Research Computing Documentation has Moved
https://docs.rc.uab.edu/


Please use the new documentation url https://docs.rc.uab.edu/ for all Research Computing documentation needs.


As a result of this move, we have deprecated use of this wiki for documentation. We are providing read-only access to the content to facilitate migration of bookmarks and to serve as an historical record. All content updates should be made at the new documentation site. The original wiki will not receive further updates.

Thank you,

The Research Computing Team

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:
ssh BlazerId@cheaha.uabgrid.uab.edu
  • 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 https://some.data.site.org/impute/1000GP_Phase3.tgz
  • 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:

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.

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.