php in background exec() function(php 后台 exec() 函数)
问题描述
我制作这个脚本是为了测试 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 的大量事件通知提醒? 和 php 执行后台过程
但是脚本的运行速度并不比没有添加 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']} &");
这篇关于php 后台 exec() 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:php 后台 exec() 函数


基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01