Running a script without a terminal session

I'm trying to figure out how I can run a script "myScript.sh" in such a way that if my remote network connection gets disconnected, the script doesn't stop functioning.

Right now I log in, run "./myScript.sh" and watch my output get pumped to a log file for about 10 hours. Only problem is that if I (or my ISP) closes my network connection ever, I have to start the whole thing all over again.

I have heard something about creating a .pid file and somehow running the script in a different session, but how do I go about doing that?

have a look at 'man nohup'

WOW thats awesome. I have been looking for that for ages!

You are my hero!

  1. nohup command = Don't send a Hang Up Signal to the process if shell exits

  2. If you don't redirect output it attempts to create a nohup.out log file in your present working directory which maybe fine, but I find UGLY.

  3. You have to background (&) the process.

  4. Best Practice, example of execution

cd /path/to/bin/directory
nohup `pwd`/script.sh 1>/path/to/logdir/logfile.out 2>&1 &