issue with shell script
hi all....
kernel: 2.4.18-14 distro: redHat 8.0 ok...I made this simple shell script to backup some folders to a zip disk. well, it works fine when I execute it [as root] manually. everything works as it should. Makes some tarballs for Data, evolution, and FTP...then it backs up data.tar.gz and emails.tar.gz to my zip disk. Again, it does the job if executed manually. However, when I schedule it via cron [for root #crontab -l reads 55 22 * * * /backup.sh] it executes only part of it. It just creates the tarball for the Data folder then it stops. any ideas why is not running the whole thing via cron? #!/bin/bash #/backup.sh #script to backup some tarballed folders on to a zip disk DATA=/backups/full-backups/Data-backup-`date '+%B.%d.%Y'`.tar.gz EMAIL=/backups/full-backups/Evolution-backup-`date '+%B.%d.%Y'`.tar.gz FTP=/backups/full-backups/FTP-backup-`date '+%B.%d.%Y'`.tar.gz # it shows what I am backing up tar -cvzpf $DATA /home/sphinx/Data tar -cvzpf $EMAIL /home/sphinx/evolution echo "Now working on FTP folder..." tar -cvzpf $FTP /home/sphinx/FTP mount /mnt/zip #mounts the zip disk rm -rf /mnt/zip/* #it erases the zip disk before dumping tarballs cp $DATA /mnt/zip cp $EMAIL /mnt/zip umount /mnt/zip #unmounts zip drive eject /mnt/zip #ejects zip disk |
My guess is its an access permissions problem. Have you checked for differences in the permissions on those directories? I'm not sure what permissions the script has when executed by cron.
|
shell script
yeah...I checked the permissions.
I even set it up chmod 777 [it was just for testing on made up test directories anyway ] backup.sh, the data, the email, and the FTP.... to make sure. and still...when I run the backup.sh script manually, it does the job. When cron runs it....it tarballs the Data directory leaving out emails and FTP directories. In fact, cron doesn't even get to the part where it tarballs emails, FTP... |
Well, start doing some diagnostics.
Have your script append stuff to a file: tar .... echo "return from tar=$?" >> diagnostic.txt tar .... echo "return from second tar=$?" >> diagnostic.txt and so on. See how far it gets and maybe it will become obvious. You might also have it right out the values of environment variables, like $USER, etc. |
All times are GMT -5. The time now is 06:44 PM. |