I have a script which starts a number of background processes and if works fine when called from the cmdline.

However the same script is also called during my xsession startup and additionally on some udev events. In both cases the background processes disappear.

I had put a sleep 10 into the script and I could see, that the bg processes are indeed started, but once the script exists it takes the bg processes with it. I tried to solve with by invoking the bg processes with start_stop_deamon --background, but this does not make a difference. Hoever, I can invoke the script from a console and exit the session and the bg processes are still running.

Other than fixing my immediate problem (though any help would be much appreciated), I am keen to understand the logic behind it all. I suspect something related to the absence of a terminal.

  • You may attach with strace -p $PID to one such background process so you will see why it exits (which signal it gets). Apr 29, 2013 at 20:18

1 Answer 1


Protect your processes with nohup:

nohup command-name &

You can also use this technique if you want to ignore stdout and stderr redirection to nohup.out:

command-name & disown

You must log in to answer this question.

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