LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2008, 01:01 PM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 490

Rep: Reputation: 30
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 . .. ..
 
Old 08-22-2008, 01:14 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
/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
while true
do
  /usr/bin/mrtg /etc/mrtg/mrtg.log >> /dev/null 2>&1
  sleep 5
done
Run that in the background, screen process or create your own startup script.
 
Old 08-22-2008, 01:20 PM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron appears to be messed up (E: cron: subprocess post-installation script returned e bujutsukai Linux - Newbie 1 07-24-2008 04:39 AM
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 09:09 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 02:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 02:50 PM


All times are GMT -5. The time now is 12:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration