php - 如果客户端浏览器丢失或关闭连接,事件脚本请求是否完成?

标签 php mysql apache http

我正在手动运行一个 PHP 数据库维护脚本,大约需要 10-15 分钟才能完成。如果我的计算机在此期间失去网络连接,脚本是否总是在服务器上完全完成,还是在途中某处停止?

如果确实停止了,我可以在 PHP 或 apache 配置中做些什么来防止这种情况发生吗?

最佳答案

看看:http://php.net/manual/en/function.ignore-user-abort.php

When running PHP as a command line script, and the script's tty goes away without the script being terminated, then the script will die the next time it tries to write anything unless ignore_user_abort is set to TRUE.

您还可以通过 CronJob 启动脚本。如果此任务是重复性的,这可能是更好的解决方案。

但在这两种解决方案中,使用 set_time_limit()确保您的 max_execution_time 不会取消脚本的执行。

关于php - 如果客户端浏览器丢失或关闭连接,事件脚本请求是否完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42457116/

相关文章:

PHP 的 include_path - 将其设置为空字符串不起作用

PHP "Use of undefined constant"来自 $_POST

php - 在 php 中按 exif 数据对图像进行排序

PHP7 和 Apache 编译警告

php - 用于根据列值分隔 HTML 表的 CSV 文件

php - 如何修复 while 循环中生成的多个 div 中的间隙?

mysql - SQL 对于每一行执行命令

mysql - ActiveRecord - 更改表以设置自动递增最小值?

php - Wordpress - 按天获取帖子和评论的数量

apache - 重写(隐藏)jsp 扩展制动 servlet