Say if I run some command in background:
./my_script.sh > /dev/null &
and I close putty immediately (which is equivalent to disconnect current session right?).
Will the background process finish? Please advise, thanks.
bashunix
Say if I run some command in background:
./my_script.sh > /dev/null &
and I close putty immediately (which is equivalent to disconnect current session right?).
Will the background process finish? Please advise, thanks.
Best Answer
When you exit an interactive bash login shell, it sends a SIGHUP to all children unless the shell option
huponexit
is set to off.When most userland processes receive a SIGHUP, they will exit.
You can also prefix the command with
nohup
to make it ignore the SIGHUP. Moreover, you candisown
it using an internal bash function.