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 :
#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"`
/bin/tar --newer-mtime $D $OPT $DEST/$D.tar.gz $SOURCE > $LOGDEST/$D.log
The log file shows TAR partially doing its thing and it just cuts off and stops.
10 00 * * * /home/username/backup.sh