I want to have a PHP program call a python program and have it run the background. When I call this from the shell nohup python3 automation.py args >/dev/null 2>&1 &
, everything runs fine. I run top
and jobs
and I can see that it is executing. The script finishes successfully.
Now I would like this script to be called from a PHP program and then run in the background, so I am using this command, which is the same above. For the program not to hang, I output it to null.
exec('nohup python3 automation.py args >/dev/null 2>&1 &')
Everything runs fine for awhile when I administer a top
but then it dies after a few seconds and I am left scratching my head to figure out why. How do I troubleshoot this?