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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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:
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
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
You are now back in the shell you left.