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.

6
  • Your 999..999 time limit comes to about a 47 bit number, far above PHP's 32bit limit.
    – Marc B
    Commented Feb 2, 2011 at 0:44
  • Are you running in SafeMode? (docs for set_time_limit )...
    – ircmaxell
    Commented Feb 2, 2011 at 0:49
  • Marc B - For this post I just press 9 many times not counting how many :) Ofkz in code I doesnt exceed 32 bits :)
    – kiler129
    Commented Feb 2, 2011 at 0:51
  • ircmaxell - nope, I`m running from console at root permissions. Btw. safe mode is depraced
    – kiler129
    Commented Feb 2, 2011 at 0:52
  • @kiler: I know it's deprecated, but safe mode has nothing to do with console or root permissions. It's a php.ini setting...
    – ircmaxell
    Commented Feb 2, 2011 at 1:06

4 Answers 4

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.

3
  • 3
    Worked like charm, I had the same error and setting max_input_time = -1 did the work. Thanks
    – amertkara
    Commented Nov 14, 2012 at 16:02
  • 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.
    – kiler129
    Commented Nov 17, 2012 at 7:45
  • 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.04 Commented Jun 18, 2014 at 15:57
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).

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. Commented Feb 2, 2011 at 16:43
  • it defaults to 300, but was it set to zero?
    – horatio
    Commented Feb 2, 2011 at 17:20
  • 1
    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 :)
    – kiler129
    Commented Feb 4, 2011 at 6:07
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;
2
  • set_time_limit() doesnt seems to help. Im running script from console on dedicated server (Im root).
    – kiler129
    Commented Feb 2, 2011 at 0:45
  • This limit is not in effect in CLI.
    – Mchl
    Commented Feb 2, 2011 at 16:32
-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

1
  • 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.
    – Max
    Commented Mar 14, 2019 at 11:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.