John Davidson

Cron every 5 second for php script

0 comments
Message:


Is there any better solution for making cron 5 sec for execute php script?


Currently, I made something like this:



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

3 of 5 based on 9271 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us