SSH session drops - Does the command continue executing?
Solution 1:
In most cases, no. Processes will be sent a SIGHUP on loss of terminal. You can prefix a command with 'nohup' to ignore the signal. See:
http://en.wikipedia.org/wiki/Nohup
Solution 2:
I'll add another heplful suggestion to the thread, something I just learned few minutes ago:
If you already started a process that will take a long time (tar restore in my case), and forgot to include nohup in front of it, you can still prevent it from terminating on logoff.
Here are the steps:
- Press Ctrl + Z - this will suspend the job
- Enter disown -h %x, where x is the job number you get after suspending the job
- Execute bg to put the job in the background
- Exit the shell and go on with your life :).
Solution 3:
Not generally, although not knowing what shell or even what OS you're running, it's tough to say. If you were running it under screen, for example, I think the behavior is to detach and continue running. Maybe some other shells have that as a configurable option.
Solution 4:
As Warner says above, the child of the ssh daemon (that is the login shell and it's children) will get SIGHUP
, but they won't get them instantly. There will be a delay, sometimes in minutes before the ssh daemon on the server side gives up on your connection. During that time the process will continue to run.
As Warner also said, the process can choose to ignore SIGHUP
, in which case, it will continue to run until it has to request input and then find STDIN
has closed.