1

I have a script:

for ($i = 0; $i <= 7200; $i++) {
    echo $i.' - ';
    sleep(1);
}

But my server has:

ini_get('max_execution_time'); // == 30

Why script runs 7200 seconds (not execution time out), but max_execution_time is 30? set_time_limit () on the server is turned off

Nadeem_MK
  • 7,317
  • 7
  • 47
  • 59
user2219071
  • 101
  • 8
  • The `set_time_limit()` function and the configuration directive `max_execution_time` only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using `system()`, the `sleep()` function, database queries, etc. is not included when determining the maximum time that the script has been running. – naththedeveloper Nov 12 '13 at 09:53

4 Answers4

4

The time you spend in sleep doesn't count towards the execution time.

Fleshgrinder
  • 15,033
  • 4
  • 46
  • 52
1

sleep time is not taking in account as it is a system call.

See How does PHP max_execution_time work?

Community
  • 1
  • 1
Rémi Benoit
  • 1,258
  • 11
  • 15
  • +1 for explanation about why it is not taken into account and providing link...I can't guess why you have got less upvotes then other here when you have given first answer – Bhavik Shah Nov 12 '13 at 09:56
0

sleep is not affected by max_execution_time

http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time

Realitätsverlust
  • 3,913
  • 2
  • 21
  • 45
0

max_execution_time only affects script time not system calls like sleep().

sleep ($seconds);

sleep — Delay execution

Krish R
  • 22,188
  • 7
  • 49
  • 57