shell script that won't run from crontab

Hi,

I have a script called backup.sh that will run fine from the command line, but doesnt run from the crontab.

The script rsyncs a directory from another server to this server, it is as follows

Code:
#!/bin/sh

LOCKFILE=/var/lock/backup.lock


if [ -f ${LOCKFILE} ]
then
   exit 0
fi

touch ${LOCKFILE}

cd /usr/backups/backup_files

rsync -avz --delete --rsh=/usr/bin/ssh [email]root@my_webserver.mydoma[/email]in:/path/to/directory/to/be/backed/up/.

rm -f ${LOCKFILE}

and in the crontab I have called it using

Code:
20 * * * *      /usr/sbin/backup.sh

The /var/log/cron says that the cron daemon tries to run the script

Code:
Jan 26 18:21:00 backup1 /usr/sbin/cron[8826]: (root) CMD (/usr/sbin/backup.sh)

There are no error messages in the /var/log/messages file and the script doesn't rsync the directory.

If I launch it from the command line then it works fine.

The system is running 6.2

Code:
FreeBSD backup 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12 11:05:30 UTC 2007     root@dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/SMP  i386

This is my first post. Apologies if I have put it in the wrong place or misformatted it.

Regards,
Oliver
 
I always add this as a header to all user crontabs.

Code:
MAILTO=""
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/$HOME/bin:/usr/local/scripts

# <min>   <hr>   <dom>   <month>   <dow>   <what to run>

This take care of the PATH issues, and unwanted emails.
Also, a remark for to help users set the time/date of the entries.
 
Back
Top