Fatal error: Maximum execution time of 0 seconds exceeded
Asked Answered
T

4

21

My script compares 2 source trees, creates a map of possible changed files, compares MD5 hashes and creates a diff-package.

After 28000-29000 files, PHP terminates the script with error:

Fatal error: Maximum execution time of 0 seconds exceeded in /root/_PACKER-TESTER/core/diff.class.php on line 67 (standard in_array() call)

I already tried to set max_input_time to high value (or zero) - nothing.

Setting max_execution_time to 99999999999999 do nothing .... the same error.

Thermel answered 2/2, 2011 at 0:37 Comment(6)
Your 999..999 time limit comes to about a 47 bit number, far above PHP's 32bit limit.Defrayal
Are you running in SafeMode? (docs for set_time_limit )...Thorrlow
Marc B - For this post I just press 9 many times not counting how many :) Ofkz in code I doesnt exceed 32 bits :)Thermel
ircmaxell - nope, I`m running from console at root permissions. Btw. safe mode is depracedThermel
@kiler: I know it's deprecated, but safe mode has nothing to do with console or root permissions. It's a php.ini setting...Thorrlow
I know :) Im expirenced programmer and linux server administrator but in this situation I havent a clue.Thermel
T
9

Problem solved, php build with litespeed api (lsapi) has extra env variable to determine max execute time - LSAPI_MAX_PROCESS_TIME (default is 300sec).

Thermel answered 2/2, 2011 at 16:28 Comment(3)
please mark your own answer as accepted to help others. and i think it would be cool if you added CLI environment to your tags/question.Illuminating
it defaults to 300, but was it set to zero?Maribeth
MAX_PROCESS_TIME is diffrent from php set time limit. Max process time has been added by litespeed tech to prevent evil script which loop for months doing nothing [set_time_limit() is cpu time, not real time]. LSAPI trigger internal php timeout mechanism, I reaported that to LiteSpeed tech. So, LSAPI_* env variables are highest priority than php values - it`s so cool on shared environments, user cant run script above global limits unless he obtain LiteSpeed Web Server config file or web panel access :)Thermel
D
31

Try setting max_input_time = -1 in php.ini, or using set_time_limit(-1). That worked for me without rebuilding PHP.

This article explains it nicely.

Davey answered 31/8, 2012 at 7:44 Comment(3)
Worked like charm, I had the same error and setting max_input_time = -1 did the work. ThanksMcglynn
It not gotta work - LSAPI_* settings have higher priority than php.ini - admin can give user access to some options of php.ini without risk due to limiting implemented by LSAPI.Thermel
Just wanted to add that it appears that setting 0 or -1 will have the same effect. Thanks for this, updating max_input_time was necessary (using set_time_limit in the code didn't change anything as appears to relate to max_execution_time which was already set to 0 for me). The error message seems to ouput whatever max_execution_time is set to even though its actually the max_input_time setting that is triggering the timeout. PHP 5.5.9 on ubuntu 14.04Herrle
T
9

Problem solved, php build with litespeed api (lsapi) has extra env variable to determine max execute time - LSAPI_MAX_PROCESS_TIME (default is 300sec).

Thermel answered 2/2, 2011 at 16:28 Comment(3)
please mark your own answer as accepted to help others. and i think it would be cool if you added CLI environment to your tags/question.Illuminating
it defaults to 300, but was it set to zero?Maribeth
MAX_PROCESS_TIME is diffrent from php set time limit. Max process time has been added by litespeed tech to prevent evil script which loop for months doing nothing [set_time_limit() is cpu time, not real time]. LSAPI trigger internal php timeout mechanism, I reaported that to LiteSpeed tech. So, LSAPI_* env variables are highest priority than php values - it`s so cool on shared environments, user cant run script above global limits unless he obtain LiteSpeed Web Server config file or web panel access :)Thermel
A
0

Try set_time_limit() and check in phpinfo() if you are able to set the time limit:

set_time_limit(60*60);phpinfo();exit;
Airport answered 2/2, 2011 at 0:42 Comment(2)
set_time_limit() doesnt seems to help. Im running script from console on dedicated server (Im root).Thermel
This limit is not in effect in CLI.Concomitance
E
-1

I've found the "max execution time of 0 seconds exceeded" can be caused by the code going into an infinite loop.

For example:

while (true) { ... }

causes this error for me.

If it's not an environment variable (as mentioned previously) I would examine what's on the line number reported by php with the error

Endospore answered 28/12, 2015 at 17:17 Comment(1)
Infinite loops are always a problem but some scripts run really long and have to run really long. So your answer is not appropriate here.Halliburton

© 2022 - 2025 — McMap. All rights reserved.