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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Third Cron Line not Running

Status
Not open for further replies.

derekwa

IS-IT--Management
Jan 28, 2005
13
0
0
US
Hello all, I am running Fedora and need to have 3 instances of mrtg run at the same time. I have added the lines to the Crontab for Root (see below) The first two work, but the third does not. I know the commands work because I can switch the lines order and it will work. Does anyone know why this last line wont' work....or a way to combine them?

Thanks,
Derek



# run-tasks
*/5 * * * * env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/httpd/mrtg/cisco2500.cfg --logging /var/log/mrtg.log

*/5 * * * * env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/httpd/mrtg/cisco1710.cfg --logging /var/log/mrtg.log

*/6 * * * * env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/httpd/mrtg/cisco2600.cfg --logging /var/log/mrtg.log

 
put the lines in a script and have only one entry?

Are you sure that you're waiting for the 6th minute to check to see if it ran or not? I notice they are /5 /5 and /6

HTH,
C
 
Chris,
I changed that to a 6 to see if maybe mrtg could not run 3 instances at the same time.


Is there a way to combine these to one?

 
yeah, create a shell script EG:

#!/bin/bash
env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/httpd/mrtg/cisco2500.cfg --logging /var/log/mrtg.log &

etc etc...


Then point your cron job at the shell script you just created

HTH!
C
 
Chris,
Thanks that worked.....however I am having another problem. I am very new to this so, please bear with me. I created a shell script with the info I need to run. I can get it to run by typing "bash /usr/local/mrtg-2/mrtg" What do i need to add to my cron. I added "*/5 * * * * /usr/local/mrtg-2/mrtg"

but it does not work..
 
When you switch the order of the lines, is it always the third line that doesn't work? If so, you might need a line feed at the end of the line. Also, some crons don't like blank lines in the crontab.

Try this for your crontab...
Code:
# run-tasks
*/5 * * * * env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/httpd/mrtg/cisco2500.cfg --logging /var/log/mrtg.log
#
*/5 * * * * env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/httpd/mrtg/cisco1710.cfg --logging /var/log/mrtg.log
#
*/6 * * * * env LANG=C /usr/local/mrtg-2/bin/mrtg /etc/httpd/mrtg/cisco2600.cfg --logging /var/log/mrtg.log
#
Also check to see if [tt]/etc/httpd/mrtg/cisco2600.cfg[/tt] is actually there and is readable (well, if this is run by [tt]root[/tt], this shouldn't be an issue).

Hope this helps.
 
I created a shell script with the info I need to run. I can get it to run by typing "bash /usr/local/mrtg-2/mrtg" What do i need to add to my cron. I added "*/5 * * * * /usr/local/mrtg-2/mrtg"

Do a "chmod 755 /usr/local/mrtg-2/mrtg" (or even 700 if no one but you needs to run it)

Tony Lawrence
Linux/Unix/Mac OS X Resources
 
Yep.. pcunix, you're most likely right.. permissions on your script need to be executable for world.

Either that or assign a specific group to the executable that "root" belongs to, and chmod 750

C
 
make sure your bash script begins with the line
#!/bin/bash

Or whatever the location of bash is for you..
And then do a

chmod +x <bashscript>
That will make the file executable.

Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
 
While it's good general advice, adding the bash bang line isn't necessary here. SHELL is going to default to /bin/sh, but there's nothing bash specific in his script so that's unimportant. If it were important, you could override SHELL in the crontab.


Tony Lawrence
Linux/Unix/Mac OS X Resources
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top