Keep processes alive after SSH logout

Use screen.

Some useful shortcuts:

  • ctrl+a+c: create a new "window"
  • ctrl+a+n: go to next "window"
  • ctrl+a+p: go to previous "window"
  • ctrl+a+d: detach the session (it keeps running)

After detaching, use screen -r to resume the session. There's also screen -x if the screen session was not detached, but went into background in some other way (or is actually still running on another terminal).

Edit in 2021: Consider tmux as well as a nicer alternative to screen.

Or, for a single process, nohup — as mentioned in other answers.


From a --help on nohup;

Usage: nohup COMMAND [ARG]...
  or:  nohup OPTION
Run COMMAND, ignoring hangup signals.

Simply add an & to your nohup <whatever you want to run> command. It'll mean that unless you specifically kill the spawned nohup process, it ain't ever going to go away.

You can skip nohup entirely with screen or tmux, which I hear will keep processes running even if the connection to the remote host is dead (which is one of it's rather awesome strengths). I don't know how to do this though, so you will need to do your own reading by doing a man screen/man tmux after downloading it.


You can prepend a program with nohup.

E.g. nohup myprogram &. That will start the program and send all output to a file called nohup.out. It will also catch the sigHUP when you log out.

Another solution is to run screen or tmux