British geneticist interested in splicing, RNA decay, and synthetic biology. This is my blog focusing on my adventures in computational biology. 

Compbio 023: Use screen to prevent compute server disconnect

People new to using ssh to connect to a remote compute server to carry out all of the memory or CPU intensive tasks that you want, such as aligning RNA-seq reads or assembling a genome, may have run into the problem that if your laptop disconnects from the server, perhaps your internet went down, then the task you were running also dies with the connection. This is THE WORST!!! To prevent this from ruining your day, you can use the software, that I think is often installed on compute server called screen. When you first log into your server and want to run screen for the first time, simply type:

screen

This will then load you into a screen session. It is exactly the same as what you normally do, but now if you disconnect, the task you are doing does not fail. If you were booted out, or chose to leave midway through a task, you can go back onto the server as usual and re-join your screen session, simply type

screen -r

This will reconnect you to the screen that you have open and you can see where you left off, saving your exact location within the file structure of the server. Brilliant. If that wasn't good enough, you can use Ctrl+a and then press another button to add extra functionality to what you do on the terminal - screen is a terminal multiplexer To open up a new "window" so you easily switch between things at once in one terminal app being open, simply do:

Ctrl+a c

To move between the new "windows" that you have opened, simply type:

Ctrl+a p

or

Ctrl+a n

This way you can easily switch between many (I often have a dozen open on my compute server) "windows" at once and when you leave the computer server and reconnect to that screen session, all of them and the locations you were in is saved. Screen is brilliant and anyone who connects to a remote compute server should know about it but I know a couple of friends who did not (because no one informed them like someone did for me) and they lost time and effort because of this.

For more reading check out:

https://linuxize.com/post/how-to-use-linux-screen/

Compbio 024: A Bioinformagician

Compbio 022: Differential splicing and transcripts - Not as simple as it first appears