PHP does not respect the maximum execution time set

916 views Asked by At

I am running scripts that last longer than the limit allowed by the server and the server does not terminate them.

The phpinfo() showed me that the max_execution_time is set to 30. Using the ini_get('max_execution_time') feature the value 30 is displayed, but I put the code with sleep(45) and it runs until the end.

I also tried decreasing the time with ini_set('max_execution_time', 15), but still the code runs normally with sleep(45).

I've used sleep for testing purposes, but this is with functions that use cURL or even foreach and while that are used to create files for users.

What could be changing the server's maximum execution time?

1

There are 1 answers

3
KIKO Software On BEST ANSWER

"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."

Copied from: sleep().

In other words: Sleep() was a bad choice for testing maximum execution time.