How to run cronjobs per second?

Have you checked my previous article on cronjobs…

https://www.svnlabs.com/blogs/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;
}
}

?>

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch