Webessence

Asynchronous execute script in PHP without fork

The usage of pcntl_fork in a webserver environment is not encouraged according the PHP documentation. As an alternative, you can use the following code:

exec("/usr/bin/php some_script.php > /dev/null &");
// Here you can do some more actions, while some_script.php
// is still executing.

Even if the caller script has ended, the some_script.php will still run. A drawback certainly is the lack of return value.

PHP | 2011-12-07 15:41:37 | Comments (1)

Comments

Beth wrote on 2012-02-18 14:56:08

Cool blog,looking to communicate

Make a comment