Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

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 can disown it using an internal bash function.

share|improve this answer
add comment

If you want backgrounded tasks to persist, look into using screen

To create or reconnect to a screen session called 'myprocess' which will persist across sessions:

  • screen -DR myprocess

To list all screens:

  • screen -ls
share|improve this answer
add comment

Yes it should. Apparently my answer was too short.

share|improve this answer
2  
The running script is still part of the shell process, even when sent to the background. Without specifying "nohup", the process will die w/ the shell on exit –  Alex Sep 16 '10 at 22:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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