[英]php in background exec() function
I made this script to test the execution of PHP as a background process 我制作了这个脚本来测试PHP的执行作为后台进程
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? 正如php过程背景中提出的以及如何使用PHP通过Google Calendar API添加大量事件通知提醒? and php execute a background process
和php执行后台进程
But the script does not run faster than when it was all in one script without the addition of test.php. 但是,如果没有添加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. exec()
将阻塞,直到您exec()
的进程完成 - 换句话说,您基本上将'test.php'作为子例程运行。 At bare minimum you need to add a &
to the command line arguments, which would put that exec()'d process into the background: 至少你需要在命令行参数中添加一个
&
,这会将exec()进程放入后台:
exec("php test.php {$test['id']} &");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.