如何使用 exec() 运行带有 POST 变量的后台 PHP 函数?

发布于 2024-10-16 20:03:39 字数 282 浏览 7 评论 0原文

exec('php convert.php >> convert.log &');

这是我找到的示例代码,但这就是我想要做的。

  1. 使用 1 个或多个 POST 运行 Convert.php 变量。

  2. 执行函数 用户离开时的背景 我们的网站。

  3. 运行多个实例 后台的convert.php 网站上同时有超过 1 位用户的情况。

exec('php convert.php >> convert.log &');

This is the sample code I found, but here's what I want to do.

  1. Run convert.php with 1 or more POST
    variables.

  2. Execute the function in the
    background in case the user leaves
    our website.

  3. Run multiple instances
    of convert.php in the background in
    case more than 1 user on the site at one time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

誰認得朕 2024-10-23 20:03:39

您不需要在另一个进程中执行该进程只是为了确保它继续运行。 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文