开发者

php in background exec() function

开发者 https://www.devze.com 2023-02-03 22:36 出处:网络
I made this script to 开发者_运维问答test the execution of PHP as a background process foreach($tests as $test) {

I made this script to 开发者_运维问答test the execution of PHP as a background process

foreach($tests as $test) { 
   exec("php test.php ".$test["id"]); 
} 

as suggested in php process background and How to add large number of event notification reminder via Google Calendar API using PHP? and php execute a background process

But the script does not run faster than when it was all in one script without the addition of test.php.

What am I doing wrong?

Thanks in advance!


exec() will block until the process you're exec'ing has completed - in otherwords, you're basically running your 'test.php' as a subroutine. At bare minimum you need to add a & to the command line arguments, which would put that exec()'d process into the background:

exec("php test.php {$test['id']} &");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号