问题
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