John David Anderson wrote:
You may not need to fork. Try appending an ampersand to the end of the command:

$ php doReportScript.php &

That'll run the process in the background (that way PHP won't wait for a return).

-- John
...
Yay!! After more googling for "php background processing" and lots of testing, I found a working cross-platform background-processing method using functions popen() and pclose(). (Never heard of those functions!) It relies on the command line ampersand concept.

Explained here:
http://robert.accettura.com/archives/2006/09/14/asynchronous-processing-with-php/

See below for the heart of the idea. Now if we can just spread the word--this is a question that has come up on a zillion forums!

-- Ken


if (is_windows()) {
 // windows uses "start /b"
 pclose(popen('start /b ' . $call, 'r'));
} else {
 // *nix uses "/dev/null &"
 pclose(popen($call . ' /dev/null &', 'r'));
}
echo "<p>Called &quot;$call&quot; without waiting for a return value</p>";


_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to