7

I have three files: monitor.sh, which starts python scripts:

sudo python ./webCheck &
sudo python ./apiCheck &

and the otherones, webCheck & apiCheck: it is supposed to run in the background, after I close the terminal. It checks my other website's availability, in an endless loop.

I can't get it to work, I am trying nohup, but can't get the syntax right. webCheck have to be run with sudo. Does nohup be included also in the sh script? I guess as the monitor.sh is just supposed to start other two, so that one doesn't need nohup.

How to do it?

Kokesh
  • 3,165
  • 7
  • 29
  • 46
  • 1
    I don't think there is anything particular to ec2 in this question, so I would check [Prevent a background process from being stopped after closing SSH client](http://stackoverflow.com/q/285015/950912) – brc Aug 22 '12 at 14:49

1 Answers1

12

You should be able to use:

sudo nohup python ./webCheck &

sudo nohup python ./apiCheck &

I don't think your monitor.sh will need it, since it should take a relatively short time to start the other two. However I'm not positive if the two checks would become children of monitor.sh, which may end up being an issue.

0TTT0
  • 1,288
  • 1
  • 13
  • 23
gsteiner
  • 776
  • 5
  • 20
  • Works, I can kill the terminal and it still runs. It didn't show up after using sudo ps, but when I do sudo ps aux | less, it shows up! – Kokesh Aug 22 '12 at 15:07
  • Glad it worked! You may also want to look at nneonneo's recommendation. Daemonizing the program could be a better solution, depending on what you're trying to do. – gsteiner Aug 22 '12 at 15:29