I created a crontab (as root) to backup my files daily. The script I execute on the command line runs fine, but when I put it in the crontab, it runs partially and just exits immediately! I have tried adding the script to /etc/crontab and it does the same thing. What is going on? My script is called backup.sh :
Code:
#!/bin/sh
#backup.sh
#tar nightly backup run at midnight
#current date minus one day to capture ALL changes from previous day
D=`date -d "-1 day" +"%Y-%m-%d"`
SOURCE=/mnt/files
DEST=/backup
OPT=-czvf
LOGDEST=/home/tar-logs
/bin/tar --newer-mtime $D $OPT $DEST/$D.tar.gz $SOURCE > $LOGDEST/$D.log
exit
The log file shows TAR partially doing its thing and it just cuts off and stops.
My crontab:
Code:
10 00 * * * /home/username/backup.sh