Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have a server running ubuntu server. It is behind a proxy...I don't know if that makes a difference. But I have found that a couple of processes I've tried, get terminated when I log out of the SSH session. For instance, I have ipython notebook server and a Mongod server processes running on that server. Whenever I logout, both of these processes die even though they are run in the background with &

I have recently discovered the nohud command which works fantastically. However, why is it that I have not encountered this with most servers? Is there some sort of default in unbuntu server that kills all processes by a user when they hangup from SSH? Can I run nohud by default for all processes?

Thank you

share|improve this question

marked as duplicate by Iain, kasperd, Ward, HopelessN00b, MadHatter Sep 3 '14 at 5:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 4 down vote accepted

Ubuntu processes handle signals the same way that other Linux distributions and Unices do. When an SSH session disconnects, a SIGHUP signal is sent to the session leader process, which would probably be bash.

Bash, in turn, cleans up after itself:

The shell exits by default upon receipt of a SIGHUP. Before exiting, an interactive shell resends the SIGHUP to all jobs, running or stopped. Stopped jobs are sent SIGCONT to ensure that they receive the SIGHUP. To prevent the shell from sending the SIGHUP signal to a particular job, it should be removed from the jobs table with the disown builtin (see Job Control Builtins) or marked to not receive SIGHUP using disown -h.

If the huponexit shell option has been set with shopt (see The Shopt Builtin), Bash sends a SIGHUP to all jobs when an interactive login shell exits.

disown is a Bash built-in command. nohup is an external command with similar effect.

I don't recommend reconfiguring Bash to not kill all of its child processes (nor do I know how to do that). Rather, a better goal would be to prevent Bash from dying when its TTY disappears. You can use screen, tmux, or mosh to keep Bash alive.

share|improve this answer
Do you know if this is the same behavior with csh or tcsh? – jwillis0720 Aug 31 '14 at 7:37
It should be the same in csh or tcsh, except that nohup is a builtin command in those shells, and disown is not. – 200_success Aug 31 '14 at 8:18
Hmm, I can't figure it out. When I look at shopt, huponexit is set to off, but I can't figure out the other servers I have been apart of seem to never have this behavior. I could just login, run a job, then log off and that job would run until completion provided it was in the background. However, I was not the server admin, and do know if the SIGTERM was overloaded...but thank you for the info – jwillis0720 Aug 31 '14 at 9:00
If huponexit is enabled, Bash sends a SIGHUP to all jobs when an interactive login shell exits. However, when huponexit is disabled, it doesn't mean that Bash will not send a SIGHUP to any jobs; it means that the default behaviour takes place. – 200_success Aug 31 '14 at 9:08
You may have been accustomed to running some processes that chose to "nohup" themselves automatically. – 200_success Aug 31 '14 at 9:09

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