LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 10-18-2002, 07:09 PM   #1
chupacabra
Member
 
Registered: Oct 2002
Posts: 30

Rep: Reputation: 15
Thumbs up 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
 
Old 10-18-2002, 07:21 PM   #2
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Rep: Reputation: 15
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.
 
Old 10-18-2002, 08:02 PM   #3
chupacabra
Member
 
Registered: Oct 2002
Posts: 30

Original Poster
Rep: Reputation: 15
Unhappy 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...
 
Old 10-18-2002, 08:12 PM   #4
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Rep: Reputation: 15
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.
 
  


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
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM
Out of guesses! (shell Script issue) chris Linux - General 2 12-10-2001 04:20 PM


All times are GMT -5. The time now is 09:21 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