[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trouble with tar



Hello, I have a script to tar up a directory that works fine when I run 
it as sudo.  When it runs in crontab it quits VERY early, and I only get 
an 8MB tar.gz file, instead of 320MB when I manually run it.

Here is the script:
#!/bin/bash
# This script makes a tar.gz file of the entire
# /usr/local/mapguideopensource directory.
# It then deletes the oldest tar.gz file.

FILE="MapGuideBackup-"
DATE=`/bin/date +%Y%m%d-%H%M`
EXT=".tar.gz"
BACKUPS="7"

if [ `ls -tr /MapGuideBackup/$FILE* | wc -l` -ge $BACKUPS ]
         then
         rm -f `ls -tr /MapGuideBackup/$FILE* | head -n 1`
fi

tar -pszcvf /MapGuideBackup/$FILE$DATE$EXT /usr/local/mapguideopensource



When I run that script with:

sudo sh ./MGBackup.sh

it runs fine and makes a 320MB tar.gz file that I can run
tar tvf filename.tar.gz and it scrolls through all the files.
When crontab runs the script with:

30 17 * * * root sh /MapGuideBackup/MGBackup.sh

it is only 8MB and when I run tar tvf filename.tar.gz on it, it only 
shows 15 lines then exits with:

tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

Can someone see what I'm doing wrong?  I'm sure it will be very obvious 
to another set of eyes.  I'd like to get this working to provide backups 
of the mapguide application I'm working on for this client.

I have ruled out timing issues.  I've run it at 10am, 5:30pm and 10pm 
and the result is the same.

Thanks,
Ray

-- 
Linux Users Of Northern Illinois - Technical Discussion 
http://luni.org/mailman/listinfo/luni


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.