LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   crontab runs and stops in middle of process. Strange! (https://www.linuxquestions.org/questions/linux-general-1/crontab-runs-and-stops-in-middle-of-process-strange-540469/)

Micro420 03-25-2007 11:31 AM

crontab runs and stops in middle of process. Strange!
 
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

jschiwal 03-26-2007 04:11 AM

I think you want to redirect both stdout and stderr to the log.
/bin/tar --newer-mtime $D $OPT $DEST/$D.tar.gz $SOURCE 2&> $LOGDEST/$D.log

Does the destination have enough space for the archive?

Micro420 03-28-2007 02:46 AM

Thanks for the suggestion of the 2&>. I see that there was not even a mount to the correct path, according to the revised log. I fixed that and everything seems to be working fine. Thanks!


All times are GMT -5. The time now is 11:26 PM.