I am experiencing a problem when using sleep() function in php for a long period of time, if i test the following code all runs perfectly:
<?php
set_time_limit(0);
$i = 0;
while($i < 10) {
echo $i.'<br />';
if($i == 5){
echo 'sleeping 5 secs<br />';
sleep(5);
echo 'waking up<br />';
}
$i++;
}
?>
*****OUTPUT****
0
1
2
3
4
5
sleeping 5 secs
waking up
6
7
8
9
*****OUTPUT****
It sleeps 5 seconds and after that the "waking up" is echoed without problems, but, if I raise the amount of seconds the script is sleeping to lets say 15 minutes the output is the following:
*****OUTPUT****
0
1
2
3
4
5
sleeping 900 secs //(15 mins)
*****OUTPUT****
The script appears to be killed after 15 minutes of sleeping!!, what could be causing this? note that I set the max_execution_time flag to infinite with set_time_limit(0); at the top of the script.
I will appreciate any help, thanks!