0

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.

3 Answers 3

4

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.

1

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
0

Yes it should. Apparently my answer was too short.

1
  • 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, 2010 at 22:57

You must log in to answer this question.

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