Friday, January 18, 2013

Linux: Start long running jobs with SSH

Recently I needed to start several long running jobs at my working machine from home using SSH. Unfortunately closing the SSH connection stops all the tasks started in this session.

Therefore we need a tool to start some tasks which will be kept running upon logout: SCREEN
There are tons of tutorials and howtos out there and a man page exists too.
However, here the most important commands and shortcuts:
Start it with typing

$ screen

then start your job, then press Ctr + A, Ctr + D  to detach the job and close the program without killing the running task. Running

$ screen -r

will resume your previous session.

Ctr + D closes the session and kills all tasks.
Ctr + A, Ctr + C opens a new screen "window",
Ctr + A, Ctr + N moves to the next window,
Ctr + A, Ctr + P moves to the previous window,
Ctr + A, Ctr + D detaches the task and closes the window,
Ctr + A, ESC enters scroll mode: use Up/Down/PgUp/PgDn to scroll, ESC again to exit this mode


  1. Hi, you might also want to look at tmux.
    Cheers /Petros

  2. screen -S label and screen -r label are usefull when you have multiple screen sessions running.

  3. I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have s ome great contents. Keep up the good work. Senior Management Jobs in London

  4. Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.
    career training

  5. Nice and Valuable information you explained in this article I loved it more, it useful for me a lot. Bookmarked your site.
    Linux Online Training in India
    Linux Online Training
    Linux Online Training in Hyderabad
    Linux Training in Hyderabad

  6. your post is very good & creativity you just have shared Jobs in Linux