about cron !!!
Dear Friends ,
I m confused about the following usage of cron : */5 * * * * /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 In the above example , what is the meaning of "/dev/null" AND what is the meaning of "2>&1" ? My second question is , is it possible to run the above script in every five seconds ? Waitig for ur kind rely . .. .. |
/dev/null 2>&1 is where the cron script or command is sending/redirecting the STDOUT and STDERR.
For more details: man stdout man stderr Cronjobs are limited to every minute. If you want something to run every 5 seconds, you'll need to write your own script. Code:
#!/bin/sh |
But if you really wanted to do this within cron, you'd have to do something like this:
* * * * * /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 5; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 10; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 15; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 20; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 25; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 30; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 35; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 40; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 45; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 50; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 * * * * * sleep 55; /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1 It's basically running the same script every minute but with the sleep command, delays the /usr/bin/mrtg command, so with those increments in seconds, would cause the command to run every 5 seconds. But I wouldn't recommend this way, especially every 5 seconds. Is there a reason you need to run every 5 seconds, is a minute at minimum not sufficient? |
All times are GMT -5. The time now is 08:30 AM. |