20

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.

Buttle Butkus
  • 9,206
  • 13
  • 79
  • 120
kiler129
  • 1,063
  • 2
  • 11
  • 21
  • Your 999..999 time limit comes to about a 47 bit number, far above PHP's 32bit limit. – Marc B Feb 02 '11 at 00:44
  • Are you running in SafeMode? ([docs for set_time_limit](http://us.php.net/set_time_limit) )... – ircmaxell Feb 02 '11 at 00: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 Feb 02 '11 at 00:51
  • ircmaxell - nope, I`m running from console at root permissions. Btw. safe mode is depraced – kiler129 Feb 02 '11 at 00: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 Feb 02 '11 at 01:06
  • I know :) I`m expirenced programmer and linux server administrator but in this situation I haven`t a clue. – kiler129 Feb 02 '11 at 01:16

4 Answers4

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.

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
theamoeba
  • 1,331
  • 13
  • 14
  • 3
    Worked like charm, I had the same error and setting max_input_time = -1 did the work. Thanks – amertkara Nov 14 '12 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 Nov 17 '12 at 07: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 – Programster Jun 18 '14 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).

neshpro9
  • 433
  • 3
  • 17
kiler129
  • 1,063
  • 2
  • 11
  • 21
  • 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. – Samuel Herzog Feb 02 '11 at 16:43
  • it defaults to 300, but was it set to zero? – horatio Feb 02 '11 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 Feb 04 '11 at 06: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;
Marc
  • 6,749
  • 9
  • 47
  • 78
-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

Alan
  • 213
  • 1
  • 4
  • 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 Mar 14 '19 at 11:18