any solution to this ?
#!/usr/bin/php -q
<?php
set_time_limit(2);
sleep(5);
echo "it didn't work again";
any solution to this ?
#!/usr/bin/php -q
<?php
set_time_limit(2);
sleep(5);
echo "it didn't work again";
The max_execution_time
limit, which is what set_time_limit
sets, counts (at least, on Linux) the time that is spent by the PHP process, while working.
Quoting the manual's page of set_time_limit()
:
Note: The
set_time_limit()
function and the configuration directivemax_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 usingsystem()
, stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.
This is not true on Windows where the measured time is real.
When, you are using sleep()
, your PHP script is not working : it's just waiting... So the 5 seconds you are waiting are not being taken into account by the max_execution_time
limit.