Expanding PHP execution time limit

孤者浪人 提交于 2019-12-24 11:46:20

问题


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

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

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.


回答1:


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)




回答2:


set_time_limit(28800);

some (shared)hosts do not allow this

what i will suggest you is maintain a log of when was your last attempt (unix time stamp), and use cron to execute a script which checks if its time to make the next HTTP request, and if yes then update the timestamp in the file to current time stamp.

Hope that helps



来源:https://stackoverflow.com/questions/6932179/expanding-php-execution-time-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!