Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a command run every 5 minutes...

Status
Not open for further replies.

MattWray

Technical User
Nov 2, 2001
2,332
US
I am trying to get a command to run every 5 minutes. It is for a Bandwidth Monitor, MRTG.
If I run the command, /usr/local/mrtg-2.9.2/bin/mrtg /home/httpd/mrtg/mrtg.cfg The files in the mrtg dir are updated.
The website with instructions said to add a line to /etc/crontab. The first line I tried was 0-59/5 * * * * root /usr/local/mrtg-2.9.2/bin/mrtg /home/httpd/mrtg/mrtg.cfg
That didn't work so I changed it to 0,5,10,15,20,25,30,35,40,45,50,55 * * * * root /usr/local/mrtg-2.9.2/bin/mrtg /home/httpd/mrtg/mrtg.cfg
Still no dice. I just need to make this command /usr/local/mrtg-2.9.2/bin/mrtg /home/httpd/mrtg/mrtg.cfg run every 5 minutes.
Please help!

Thanks,

Matt Wray
MCSE, MCSA, MCP, CCNA

 
I got it. When I typed crontab -e ,it said opening empty container. But if I ran vi crontab from the /etc dir, it would open. I added the lines in the /etc dir cron. Must have been the wrong one, I tried crontab -e, made a new cron file for root, added my line, saved it and it is now running.
Hope this can help someone else!

Thanks,

Matt Wray
MCSE, MCSA, MCP, CCNA

 
mattwary

Just a tip, because you are running Linux you don't have to specify each 5 minute interval in your crontab, you can specify each 5 minutes like this

*/5 * * * * command_name

It works the same as your entry but it's just a bit tidier.

For more details refer to the man page for crontab in section 5 (man -S5 crontab)

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top