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?

2

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.