RSS

Tag Archives: cronjobs

How to run cronjobs per second?

Have you checked my previous article on cronjobs…

http://blog.svnlabs.com/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;
}
}

?>

 
1 Comment

Posted by on August 21, 2010 in CentOS, Fedora, Linux, Tricks

 

Tags: , , , ,

Crontab Command Line

crontab Crontab Command Line

1. dump the content of the existing crontab to a file
# crontab > /tmp/dump
2. echo “your lines” >> to the corntab file
# echo ” 00 1 * * * /monitor_file_system 2>/dev/null” >> /tmp/dump
3. import the new crontab
# crontab /tmp/dump

other option….
# crontab -e
It will open a editor, add job here like
00 1 * * * /monitor_file_system 2>/dev/null

Set cronjob from other server:
# crontab -e
0 0 * * * curl http://www.domain.com/svnlabs.php

here svnlabs.php file is located on different server…

and save this crontab files…. now cronjob successfully installed 🙂

 

Tags: , , , , , , , , ,