Have you checked my previous article on cronjobs…
http://blog.phpsolutions.co.in/tag/crontab-command-line/
To run cronjob per second you have to execute crontab/cronjob per minute and then have to run task in cron file per second using PHP function time_sleep_until().
<?php
$start = microtime(true);
for($ii=0;$ii<60;$ii++)
{
//……………………….
/// here is the tasks which need to run per second…
//……………………….
time_sleep_until($start + $ii + 1);
} // end for
if (!function_exists(‘time_sleep_until’))
{
function time_sleep_until($future)
{
if ($future < time())
{
trigger_error(“Time in past”, E_USER_WARNING);
return false;
}
usleep(($future – microtime(1))*1000000);
return true;
}
}
?>
One Response to How to run cronjobs per second?
Leave a Reply
You must be logged in to post a comment.
I had been just browsing here and there along with to read this post. I have to admit that i’m from the hand of luck today if not getting this excellent post to see wouldn’t are already achievable for me, at least. Really appreciate your articles.