Reputation: 557
I have a PHP script running a loop which could go on for hours on end. However after about 50 minutes I get the following error although the script is far beyond 60 seconds:
Fatal error: Maximum execution time of 60 seconds exceeded in /path/script.php on line 275
The memory usage by the time the script fails is 11359848 Bytes - 10.8336 MB. Any ideas what sort of thing could actually be causing the script to trip out like this?
Upvotes: 1
Views: 890
Reputation: 318508
The maximum execution time is not real time but CPU time.
So if send e.g. a HTTP request that takes 10 hours to finish (i.e. you wait for I/O) you can easily stay within the 60-second limit. But if try breaking a hash using brute force (i.e. something where the script is actually doing something) you'll hit the time limit after pretty much 60s of real time.
The solution for your problem is pretty simple: set_time_limit(0);
disables the time limit unless PHP is running in safe_mode, but if that's the case it's time to chance the hosting company.
Upvotes: 6