后台exec()函数中的php [英] php in background exec() function
本文介绍了后台exec()函数中的php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我制作了这个脚本来测试PHP作为后台进程的执行情况
I made this script to test the execution of PHP as a background process
foreach($tests as $test) {
exec("php test.php ".$test["id"]);
}
如 php进程背景中所建议 和如何添加和 php通过Google Calendar API进行大量事件通知提醒处理
但是该脚本的运行速度不会比不添加test.php的脚本运行速度更快.
But the script does not run faster than when it was all in one script without the addition of test.php.
我做错了什么?
提前谢谢!
推荐答案
exec()
将阻塞,直到您执行的过程完成为止-换句话说,您基本上是将'test.php'作为子程序.至少需要在命令行参数中添加&
,这会将exec()处理的进程置于后台:
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']} &");
这篇关于后台exec()函数中的php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文