使用庞大的PHP脚本防止504网关超时 [英] Preventing a 504 Gateway Timeout with huge PHP script

查看:513
本文介绍了使用庞大的PHP脚本防止504网关超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在本地计算机(Windows)上运行Apache服务器(2.2),该服务器用于运行一些PHP脚本来完成一些繁琐的工作.其中一个脚本涉及大量移动,调整大小以及将文件下载/上传到另一台服务器.我非常希望脚本能够不断运行,这样我就不必每次超时都重新启动该脚本.

I'm currently running an Apache server (2.2) on my local machine (Windows) which I'm using to run some PHP scripts to take care of some tedious work. One of the scripts involves a ton of moving, resizing, and download / uploading files to another server. I would very much like the script to run constantly so that I don't have to baby the script by starting it up again every time it times out.

set_time_limit(0);
ignore_user_abort(1);

两者都在我的脚本中设置,但是大约30分钟到一个小时后,脚本停止了,并且我在浏览器中收到504网关超时消息.我在Apache或PHP中缺少一些东西来防止超时吗?还是应该以其他方式运行脚本?

Both are set in my script, but after about 30mins to an hour the script stops and I get the 504 Gateway Time-out message in my browser. Is there something I missing in Apache or PHP to prevent the timeout? Or should I be running the script a different way?

推荐答案

还是应该以其他方式运行脚本?

Or should I be running the script a different way?

当然.您应该从命令行运行脚本( CLI )

Definitely. You should run your script from command line (CLI)

这篇关于使用庞大的PHP脚本防止504网关超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆