Using Screens when working with remote servers

This will be a short post on using screen sessions when running long jobs on remote servers. Using screen session will help if you don't want something that is running to stop when you loose connection to the server. I use this when i run long running jobs on the super computers at my lab in interactive mode. But this can be useful with any remote server so i thought i should to a small write up regarding this.

Installation

First you would need to make sure that the remote server ( Linux based ) has screen installed. just type the following command to check the screen version, if it is not installed you would have to install it or ask the system admin to install it for you.
 $ screen -version
Screen installation command
 $ sudo apt-get install screen

How it works

How screens work is simple to understand. After login in to the remote server you create a screen session and continue work inside the screen session. You can run something in the screen session and leave the screen session and work on something else while the screen session will keep running. The best part is even if you get disconnected from the server the screen session will keep running and once you login again you can simply reconnect to the session and continue your work without and problem. 

I am listing only the basics that you would need you can get a more detailed options from the man page of the command "man screen"

Creating a Screen session.

You can create a screen session with the simple command given below.
 $ screen -S name

This will create a screen with the name and attach you into the screen. That is after the command you will be in the screen. You can list the current screens and the status using the following command. You will notice that the one you just created will be listed as "Attached".
 $ screen -ls

Existing the screen session

If you want to exit and kill the current screen that you are in just type the following command
 $ exit

If you want to exit the screen but want to keep the screen running use CTRL + a + d. Now if you list the screens you will see that the screen is listed as "Detached".

Joining a current screen session

If you want to join a current screen session you can use the following command. If you do not remember the names of the screens you can use the list command and then figure out the name. The command will work with a partial name if the partial name is unique among the current screen sessions.
 $ screen -x name

I hope this post helps. Screens have been very useful to me when working on a remote server because you don't need to worry about connection issues. 

Comments

Popular posts from this blog

Setting up Heron Cluster with Apache Aurora Locally

Reading and Writing Binary files in java - Converting Endianness ( between Big-endian byte order and Little-endian byte order)

Writing Unit Tests to test JMS Queue listener code with ActiveMQ