View previous topic :: View next topic |
Author |
Message |
ianw1974 Guru
Joined: 18 Oct 2006 Posts: 387 Location: UK and Poland
|
Posted: Tue Mar 04, 2008 11:58 am Post subject: Vixie-cron not running my scheduled job. |
|
|
I wanted to use the /etc/crontab file for running a job every five minutes. I did this:
Code: | mkdir /etc/cron.fivemins |
and put a script in there that I created to update my mrtg, which contains:
Code: | #!/bin/bash
mrtg /etc/mrtg/system.cfg |
I made sure it was executable with:
Code: | chmod +x /etc/cron.fivemins/mrtg_update |
My /etc/crontab contains:
Code: | # for vixie cron
#
# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.1 2005/03/04 23:59:48 ciaranm Exp $
#
#
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# check scripts in cron.fivemins, cron.hourly, cron.daily, cron.weekly and cron.monthly
*/5 * * * * root rm -f /var/spool/cron/lastrun/cron.fivemins
0 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
1 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
15 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
30 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons |
so I basically set it up like it would normally be based on the other existing scripts that run fine with this config. I can see in the log file that the job is running every five minutes, but it's not actually doing anything. The logfile shows:
Code: | Mar 4 11:30:01 mail2 cron[16609]: (root) CMD (rm -f /var/spool/cron/lastrun/cron.fivemins) |
but wasn't running the script within the directory cron.fivemins. Is there something else I'm missing to get it to run this script? Normally, I just drop stuff in cron.daily or cron.hourly and this is OK. But I wanted to run this script every five mins, and without creating a crontab for a particular user - would rather set it up like I've outlined here.
Any ideas? _________________ Ian Walker
Light travels faster than sound. This is why some people appear bright until you hear them speak.........
Linux Systems Limited | Masternode Monitoring |
|
Back to top |
|
|
oliver Apprentice
Joined: 25 Jun 2003 Posts: 170
|
Posted: Tue Mar 04, 2008 3:12 pm Post subject: |
|
|
does /var/log/syslog give any clues? |
|
Back to top |
|
|
andreas_st Tux's lil' helper
Joined: 26 Dec 2007 Posts: 112 Location: 48N 16E
|
Posted: Tue Mar 04, 2008 3:51 pm Post subject: |
|
|
As far as I can see you have not set up anything that would run your cron job. All you are doing is deleting a nonexisting file every five minutes. If you want to do it that way you would have to edit /usr/sbin/run-crons but I really see no advantage compared to a traditional crontab entry. _________________ Registered Linux user #62727 |
|
Back to top |
|
|
ianw1974 Guru
Joined: 18 Oct 2006 Posts: 387 Location: UK and Poland
|
Posted: Tue Mar 04, 2008 7:04 pm Post subject: |
|
|
I did add it differently to /etc/crontab this time, and now it's working fine. I was wondering if there was some other file to edit to get it to work, and did wonder about why /etc/crontab was set up like this. But kinda makes sense now _________________ Ian Walker
Light travels faster than sound. This is why some people appear bright until you hear them speak.........
Linux Systems Limited | Masternode Monitoring |
|
Back to top |
|
|
|