1

Say, I ssh into a remote host, initiate few processes on it and disconnect before the processes terminate. What happens to the processes?

Do they continue?

1 Answer 1

3

As the process is a child of the shell you opened over ssh, this process will be terminated as soon as you log out of the shell, e.g. by disconnecting.

You can use different methods to work around this:

  1. Start the program with nohup (no hang up) and disown it:

    nohup somecommand &
    disown %1
    

    This will redirect all ouput to a file $PWD/nohup.out, if you want to discard the output, pipe it into /dev/null (between somecommand and &)

  2. Use a terminal multiplexer, like GNU Screen or tmux:

    tmux
    #Inside tmux
    somecommand
    

    Then detach from the tmux session using Ctrl+B, followed by D. You can now safely disconnect. When you want to get the tmux session back in another shell, simply run

    tmux a
    

    You are now back in the shell you left.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .