如何使用 exec() 运行带有 POST 变量的后台 PHP 函数?
exec('php convert.php >> convert.log &');
这是我找到的示例代码,但这就是我想要做的。
使用 1 个或多个 POST 运行 Convert.php 变量。
执行函数 用户离开时的背景 我们的网站。
运行多个实例 后台的convert.php 网站上同时有超过 1 位用户的情况。
exec('php convert.php >> convert.log &');
This is the sample code I found, but here's what I want to do.
Run convert.php with 1 or more POST
variables.Execute the function in the
background in case the user leaves
our website.Run multiple instances
of convert.php in the background in
case more than 1 user on the site at one time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要在另一个进程中执行该进程只是为了确保它继续运行。 PHP 有一个内置的功能。
ignore_user_abort() 如果为 true,即使用户在运行时离开,当前脚本也会完成。
编辑:正如评论中指出的,您还需要禁用时间限制。使用 set_time_limit(0)
You do not need to execute the process in another process just to ensure that it continues to run. PHP has a built in feature for that.
ignore_user_abort() if true the current script will finish even if the user leaves while it's running.
Edit: as pointed out in comment you also need to disable time limit. Use set_time_limit(0)