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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-18-2002, 07:09 PM
|
#1
|
|
Member
Registered: Oct 2002
Posts: 30
Rep:
|
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
|
|
|
|
10-18-2002, 07:21 PM
|
#2
|
|
Member
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136
Rep:
|
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.
|
|
|
|
10-18-2002, 08:02 PM
|
#3
|
|
Member
Registered: Oct 2002
Posts: 30
Original Poster
Rep:
|
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...
|
|
|
|
10-18-2002, 08:12 PM
|
#4
|
|
Member
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136
Rep:
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:10 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|