LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-25-2007, 11:31 AM   #1
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
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

Last edited by Micro420; 03-25-2007 at 11:36 AM.
 
Old 03-26-2007, 04:11 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
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?

Last edited by jschiwal; 03-26-2007 at 04:17 AM.
 
Old 03-28-2007, 02:46 AM   #3
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shared printer stops printing in the middle of jobs rfrey74 Linux - Networking 14 04-29-2006 11:15 PM
Installation stops in the middle of bootup (on new machine) lostinpurdy Linux - Newbie 4 10-05-2005 09:12 PM
slax stops in the middle of boot-up aquilolumen Slackware 13 08-15-2005 12:09 AM
cron stops in the middle of the script djzanni Linux - Newbie 6 06-02-2005 05:29 PM
Why my installation stops in middle vivek007 Red Hat 3 10-31-2003 11:00 AM


All times are GMT -5. The time now is 05:43 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration