I started offloading some of the heavy-lifting and the more time-consuming jobs to my server. While I am more and more comfortable of using the ssh terminal, the mayor problem was that scripts only worked as long as I was logged in. Which goes completely against the whole idea of laying off work to the server. After some goggling I found the small tool “screen” which is available for linux. A more comprehensive introduction can be found here, but after installing I only used three commands: “screen” to start; “screen -ls” to list the open terminals after reconnection, and “screen -r XXX” to reconnect to a running terminal.

Installation

With my Linux (ubuntu) server all I had to do to install it was a simple
$ sudo apt-get install screen

Use

After that you can start screen by simply typing:
$ screen

Now start your time-consuming job and just quit the terminal whenever you can’t stand waiting any longer. Whenever you want to have a look again just connect via ssh, and get a list of open screens:

$ screen -ls

this gave me:
3467.pts-0.MYSERVER (09/14/2011 08:59:46 PM) (Detached)
2238.pts-0.MYSERVER (09/14/2011 08:45:13 PM) (Attached)
2 Sockets in /var/run/screen/S-gerhi.

To reconnect to the first of these still running terminals, you just enter:
$ screen -r 3467.pts-0.MYSERVER

 

Free PDF    Send article as PDF   
 

One Response to Keep ssh-scripts running without a connection – “screen” for Linux

  1. [...] from the blog Sustainable Research posted a nice article about the screen-command for the linux console that allows you to run scripts in the background [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.