1

Sorry for the noob question. I'm running a shell script on my webserver to download 900 or so files. However I'm doing this through a Terminal shell on my laptop and I'm about to lose my current Internet connection.

Does the script on the server continue running until finished? Or does it stop because its no longer providing feedback to my terminal on the disconnected laptop.

fish
  • 21
  • 2

2 Answers2

1

By default, your interactive shell on the web server will send your script a HUP signal as soon as it terminates. You can prevent this by calling your script like this:

<scriptname> & disown

This way it will be run in the background (&) and removed from the shell's job list (disown), so the shell will not send it a HUP signal.

Note that the disown may not be necessary in some cases.

Michael Jaros
  • 4,586
  • 1
  • 22
  • 39
0

It will die as the parent process (the terminal) has died. However, using utilities such as screen or nohup (among others) it is possible to have the process continue even if the terminal dies, and you can even background a process and disown it after its already running, see this Q for more there.

Further reading you may want to peruse, there's a ton out there on this subject.

Community
  • 1
  • 1
zzevannn
  • 3,414
  • 2
  • 12
  • 20