Currently I have a problem with GoDaddy and its hosting. The maximum amount of time allowed for a PHP script to run is set to 120 seconds = 2 mins.
Sometimes when I run my script, it takes more than 120 seconds and sometimes it takes 30 seconds.
When it takes over 120 seconds, I get a Internal Server Error (500)
.
The question I have is, is it possible to figure out if a script run time is at 110 seconds and then refresh the page so that the Internal Server Error does not occur.
If what ever is causing your script to run long is some sort of self contained blocking function (like a database query), then you are kind of screwed.
If not, say you are in a very large loop, then just do the math your self.
At the very start of your script, save the current time: $t_start = time();
Then at the top of your loop, do a $runtime = time() - $t_start;
then you have how long you have been running, and can use that to break your loop gracefully if nearing your 120 limit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With