screen: Keep Linux Sessions Alive (so you can go back to the same terminal window from anywhere, anytime)

Some bioinformatics software pipeline need long time to run and need us to monitor the progress from time to time. But we often can not keep our computer always on to keep the linux session on. Also the internet connection may get lost, then you will miss the session.

Thanks to the Linux developers for the screen command, which can easily help us keep as many sessions as we want alive.

Jump start: If you don't want to understand the details, here is my simple and easy way to use screen.

First, login to O2 using Linux/Mac terminal or Putty on Windows. 

Second, copy over a screen configure file to your home using this command: 

1 ld32@login01:~$ cp /n/shared_db/misc/rcbio/data/screenrc.template.txt ~/.screenrc

Note that you only need to copy this file once.

Next you can start a screen session: 

1 ld32@login01:~$ screen

Please note, we start the screen session on login01 here. Your node may be login02 or any other login nodes. You need remember it to you can come back later.

Now you should have a window like: 

So there are 4 windows (test1, test2, run1 and run2) inside the screen. Each time, only one highlighted window is active ("run2" as shown above). Press Ctrl-a ("Ctrl" key and "a" key together), then number 1 or 2 to activate one of the 2 windows. You can also press Ctrl-a twice to go back the previous window. You can do different things inside each window.

When you need turn off your computer or log out of O2, press Ctrl-a, then d. Screen is detached.

Then press Ctrl-d, will log out of O2 and close putty.

When you want to go back to the previous Screen, first log on to O2 as before, check if you land on the original screen session's starting node or not, if not ssh to the original screen session's starting node, then run command 'screen -Dr':

1 2 ld32@login02:~$ ssh login01 ld32@login01:~$ screen -Dr

Note 1: -Dr, means detatch Screen first if it is not done already (e.g. you forget to detach in your office, but now you are at home), then re-attach it.

Note2 : Because Screen session is linked with the original starting node, make sure you are on the same login node as you created the Screen (here it is login01).

# For Detail: please refer to this page: