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

5 comments:

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

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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete