Shell Script works different from cron
I wrote a simple shell script for backing up my home directory using the tar command. If I run the script from the command line then it backs up my files as required. Everything seems to work fine. However, when I run it from cron my results are different. It still creates a backup file however, all of the directories in the .tar file are empty. No actual files are backed up.
Here's the part of the script that actually does the backing up...
if test -f /home/necrolin/.homebackup/snapshots/l0snapshot
# Copy snapshot files to avoid errors
cp /home/necrolin/.homebackup/snapshots/l0snapshot /home/necrolin/.homebackup/l1snapshot
# Run backup
tar -cvf /home/backup/level1.tar \
--label="Level 1 backup executed on: `date`" \
-g /home/necrolin/.homebackup/l1snapshot /home/necrolin
# Copy snapshot file for use with level 2 backups
cp /home/necrolin/.homebackup/l1snapshot /home/necrolin/.homebackup/snapshots/l1snapshot
echo "You must run a level 0 backup before you can run a level 1 backup"
Last edited by necrolin; 05-06-2009 at 08:55 PM.