Expanding PHP execution time limit

2019-08-15 19:16发布

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.

2条回答
爷、活的狠高调
2楼-- · 2019-08-15 19:36
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

查看更多
甜甜的少女心
3楼-- · 2019-08-15 19:42

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)

查看更多
登录 后发表回答