Running a process in the background from php

So earlier this week I had a little problem with Apache/PHP killing the task I had running. So after looking around a little online I got some hints and finally came to the conclusion on this line:

echo exec(sprintf("rsh [server] 'nohup %s > %s 2>&1 & echo $! > %s'", 
  "/usr/bin/python2.7 [python script]", 
  "[log file]", 
  "[pid id file]"));

Something to remember, of course this is for Linux

Posted by Stuart James Saturday, January 25, 2014 3:06:00 PM
Stuart James