Is there any better solution for making cron 5 sec for execute php script?
Currently, I made something like this:
- crone1minTo5sec.php
$defDelay = 5;
for($k=0;$k<12; $k++) {
$timeStart = time();
echo "Here my script for execute";
$timeStop = time();
$diff = $timeStop - $timeStart;
if($diff > $defDelay) {
$wait = $diff - $defDelay;
$now_wait = $defDelay - $wait;
if($now_wait >0 )
{
sleep($now_wait);
continue;
}else
{
$now_wait = -1 * $now_wait;
$loopLess = ceil($now_wait / $defDelay);
$k += $loopLess;
continue;
}
}
sleep($defDelay);
}
and crontab -e
- /usr/bin/php7.4 /var/www/public_html/crone1minTo5sec.php
My Answer:
=12;$k++){_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Rate this post
5 of 5 based on 8187 votesComments