Search code examples
sshamazon-ec2shbitnami

How to start process via SSH, so it keeps running?


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?


Solution

  • 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.