Because until $r['dtimestamp'] > $cur_time you have told it to sleep 10 and do clearstatcache(),
while ($r['dtimestamp'] <= $cur_time) {
sleep(10);
clearstatcache();
}
it is only once $r['dtimestamp'] > $cur_time that it gets out of your while loop and if $r['dtimestamp'] < $cur_time to start with it will never suddenly get > unless something in clearstatcache is changing $cur_time