扩展PHP执行时间限制 [英] Expanding PHP execution time limit

查看:123
本文介绍了扩展PHP执行时间限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对PHP的执行期限有疑问.我需要运行多个小时来发送HTTP请求的脚本.这些请求必须分开一定的时间,所以这就是为什么整个过程要花几个小时的原因.有人有使用下面的代码为PHP设置这种时间限制的经验吗?例如:

I have a question about PHP's execution time limit. I need to run a script for many hours sending HTTP requests. These requests have to be apart a certain time, so that's why the whole thing is supposed to take hours. Does someone have experience setting this kind of time limit for PHP using the line below? For example:

ini_set('max_execution_time', 28800);    // 8 hours

我知道一个奇怪的问题,但是请告诉我这是否可行. TIA!

Strange question, I know, but let me know if this would work or not. TIA!

更新:我打算从浏览器尝试一下.我不熟悉从命令行运行PHP脚本的情况.我确实找到了另一种方法来获取可以从HTTP请求中检索的信息.事实证明,我们有一个数据库,其中一些信息已经在很长一段时间内本地积累了.

Update: I was going to try it from the browser. I'm not familiar with running PHP scripts from the command line.. I should look into this. I did found an alternate way to get this information that could be retrieved from the HTTP request; It turns out we have a database with some of the information already locally accumulated over a long period of time.

推荐答案

您是通过浏览器还是CLI运行此程序?如果从CLI中执行(如您应该使用该脚本那样),则没有执行时间限制(即max_execution_time硬编码为0)

Are you running this from browser or from CLI? If from CLI (as you should with such script), there is no exection time limit (i.e. max_execution_time is hardcoded to 0)

这篇关于扩展PHP执行时间限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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