Faced a problem with the script. In php.ini settings:

 max_execution_time = 30 

But the script continues to work even after five minutes, but it also does not hang - it works until victory (without endless cycles, just a long time). Obviously, the directives in the script are not rewritten. Question: where else to see the script to complete the work in due time, and not clogged the resources?

php 5.6.30, Red Hat 4.8.5-11

  • What does the script do? Under * nix, max_execution_time includes the time spent on the PHP code itself, and not the real-time timer. In particular, network calls for all sorts of api are not considered. - Fine
  • those. on the whole script minus requests? - I. Belikov
  • Or even like this: 30 seconds per script + time for requests? - I. Belikov

2 answers 2

http://php.net/manual/ru/function.set-time-limit.php

1) Warning This function does not work if PHP is running in safe mode (safe mode). You can bypass this restriction only by turning off safe mode or changing the setting value in php.ini.

2) Note: The set_time_limit () function and the max_execution_time directive affect the execution time of the script itself. The time spent on various actions outside the script, such as system calls of the system () function, streaming operations, database queries, etc. not included in the calculation of the execution time of the script. This does not apply to Windows systems where the absolute execution time is calculated.

3) Create an empty page and display phpinfo (); - see if the value is being overwritten. Possibly rewritten in .htaccess

    Do you have inside something like a cycle or some kind of marks, iterations? Add $ time1 to the beginning of the script the rest of the code in each iteration.

     $time1 = microtime(true); $time2 = microtime(true); $time3 = $time2-$time1; if($time3 > 30){ exit('время вышло'); } 
    • Option, but alas, the question is not ( - I. Belikov