Can't exec immediate (background) from php53

software development


Hey kids, I have a php page that needs to spin off a separate long running php script (exec) and background it (return immediately). I’m using the following line:
exec(’/usr/local/php53/bin/php /path/to/my.php > /dev/null 2>&1 &’);

However, my php does not return immediately as I would expect. I’ve also tried the cgi variant and php5(.2) to no avail. I’ve also tried to wrap the php cli with a bash -c “exec nohup setsid …” which also did not return immediately. Can someone tell me what I’m doing wrong here? Also, can someone let me know the best way to log debug output from php (without writing out to the browser) and where to find the logging?

thanks in advance,


Write your nohup command in a bash script and call it from the client-facing PHP file.