Not sure if this is more appropriate for Server Fault or Stack Overflow, but here goes.
I'm using mod_php on Apache MPM prefork and spawning a new process like-so:
<?php
exec("/usr/bin/php -f backgroundScript.php &");
?>
Assuming that the new backgroundScript.php child process runs for a long timeā¦
1) Is the parent PHP process now considered idle? Does it return to the server pool?
2) If Apache does kill the parent PHP process to return to MinSpareServers
, will backgroundScript.php also get cleaned-up or continue running indefinitely?
3) Are there other ways that Apache may inadvertently kill the backgroundScript.php child process? service httpd stop
perhaps?
Best Answer
You want to run application in background and forget?
there are many posts regarding this on php.net
Also, note from the exec man:
same here and here and here etc
I've got ugly code, violating these rules:
Just tested on my fedora box with default apache+php (prefork + module), i've killed processes with killall -9 /usr/sbin/httpd
&
- no, didn't, it's still considered as running. my background app is still runningAfter adding
/dev/null
- everything's fine, parent process id is "1".