I'm having a problem with my PHP file that takes more than 30 seconds to execute.
After searching, I added set_time_limit(0);
at the start of the code,cbut the file still times out with a 500 error
after 30 seconds.
log: PHP Fatal error: Maximum execution time of 30 seconds exceeded in /xxx/xx/xxx.php safe-mode : off
Syntax: set_time_limit ( int $seconds ) Return Value: Boolean ( True or False ) Default value:30 seconds. For the maximum or you can say for the infinite execution time, we can set the function with the 0 value. If the value is 0 then it will run for an infinite time.
When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.
Just increase the max_execution_time in php. ini. Set it to 1800 and restart your apache or any other server you are using.
This is an old thread, but I thought I would post this link, as it helped me quite a bit on this issue. Essentially what it's saying is the server configuration can override the php config. From the article:
For example mod_fastcgi has an option called "-idle-timeout" which controls the idle time of the script. So if the script does not output anything to the fastcgi handler for that many seconds then fastcgi would terminate it. The setup is somewhat like this:
Apache <-> mod_fastcgi <-> php processes
The article has other examples and further explanation. Hope this helps somebody else.
Check the php.ini
ini_set('max_execution_time', 300); //300 seconds = 5 minutes ini_set('max_execution_time', 0); //0=NOLIMIT
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