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!

Cron job won't execute

Status
Not open for further replies.

Roberti

Technical User
Mar 2, 2001
96
0
0
NL
I've made a script that that will launch rsync. I've tested the script and it works. I've put the following in cron:

Code:
1  9  *  *  * root /usr/local/etc/rc.d/rsync.sh

This should execute the scipt everyday at 9:01, but it doesn't. when I check the log I see the job at 9:01 with no errors, but no new data is rsynced. Does anybody have an idea?

FreeBSD: 5.3
 
That was always necesary in FreeBSD 4.10
 
OK. Never have used that on AIX or Solaris. Anyway, your problem is in your environment.
 
Hi,

Get rid of "root" text.
Example:

01 09 * * * /usr/local/etc/rc.d/rsync.sh

...........
dbase77
 
When I do that I get a parse error in the cron log.
 
Hi,

Can you paste me the error? And what happen when you run /usr/local/etc/rc.d/rsync.sh from command line?

I've created/tested using simple shell script and it worked fine. If you put root in front of it, you are going to get an error. I'm running freebsd4.x as well.

try redirect the error to log file and paste here back.

01 09 * * * /usr/local/etc/rc.d/rsync.sh >> /var/log/test.log

.......
dbase77


 
This is the error when I leave out the root command:

Code:
Feb 8 08:56:00 testserver /usr/sbin/cron[454]: (*system*) PARSE (bad command)

When I run the script from the command line it run's fine.
With the root part in cron the job doesn't produce an error, but the script doesn't run.

P.S. I'm running FreeBSD 5.3 (as stated in my opening post), but with FreeBSD 4.10 I also needed the root part.
 
Hi,

hmmm. I assume you are setting root cronjob. Can you post your rsync.sh script? I wonder if the system doesnt like some of the command within the script.

........
dbase77
 
This is the script:

Code:
#!/bin/sh

/usr/local/bin/rsync -a --delete --progress ftp-rsync.mozilla.org::mozilla/ /usr/local/ftproot/pub/mozilla/
 
Hi,

You are using /etc/crontab, right? I thought you are using "crontab -e" command to set root cronjob. If you use /etc/crontab file, yes you need "root" user entry along the line. Can you try redirect the output to log file? See if you getting any error.

.........
dbase77
 
Hi again,

/etc/crontab is system cronjob. If you want to run root cronjob, you can use " crontab -e". Its your choice basically.

........
dbase77
 
Cron works now, I have no idea why. I added the '>> /var/log/rsync.log' part to create a logfile and changed the time. Crontab now looks like:

Code:
10  9  *  *  * root /usr/local/etc/rc.d/rsync.sh

The logfile shows the transfers made and everything is fine.
Thanks everybody for the tips, I'm glad it works now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top