The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
tar -xvf doesnt work lo-lp-kl AIX 2 05-19-2008 07:46 PM
cp doesnt work - Help rudi.okelly UNIX for Dummies Questions & Answers 26 01-04-2007 08:53 AM
SSH doesnt exit properly from command line frustrated1 SUN Solaris 4 06-16-2005 04:30 PM
cd.. doesnt work rintingtong UNIX for Dummies Questions & Answers 2 07-29-2004 02:30 PM
why doesnt my script work!!! Heedunk Shell Programming and Scripting 7 03-01-2004 05:03 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-10-2009
digitalrg's Avatar
digitalrg digitalrg is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 26
A script doesnt work properly when crontab

Hi,

I have a script which does a tar and sends it to another server as backup.
Script is as below

# Locations to be backed up. Seperate by space
BACKUP_LOCATIONS=/repos/subversion

BACKUP_BASE_FOLDER=/bakpool
BACKUP_FILE_NAME_ROOT=svn-backup

START_TIME_DISP=`date`
START_TIME=`date +%Y%m%d%H%M%S`
BACKUP_FILE=${BACKUP_BASE_FOLDER}/${BACKUP_FILE_NAME_ROOT}-${START_TIME}.tar

# Run the backup
/usr/bin/tar -cvf ${BACKUP_FILE} ${BACKUP_LOCATIONS}
#scp ${BACKUP_FILE} m1008366@57.5.198.208:/backup/svn/fops << PPASS
/usr/bin/scp ${BACKUP_FILE} m1008366@57.6.198.206:/backup/svn/fops << PPASS
intel2707
PPASS


When i run this scrip manually it gives back up of size 2862295040 however if i crontab it it just results in the size 38881280. my crontab settings are
1 11 * * 1-6 . /scripts/backup-script.sh
Please help....
Regards..
RG
  #2 (permalink)  
Old 04-10-2009
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Are you sure that same versions of tar is being used when run manually and via cron?

Tip:
Use -C option with scp for on the fly compress while transferring
  #3 (permalink)  
Old 04-10-2009
digitalrg's Avatar
digitalrg digitalrg is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 26
Yes Matrix... same versions of tar are being used...... Iam really confused how come the same script will work perfectly when we run manually...
Regarding SCP no issues i can do that, thanks for the tip...
Can u please dig more and report me
thanks again
  #4 (permalink)  
Old 04-10-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
Quote:
Originally Posted by digitalrg View Post
Yes Matrix... same versions of tar are being used...... Iam really confused how come the same script will work perfectly when we run manually...
Regarding SCP no issues i can do that, thanks for the tip...
Can u please dig more and report me
thanks again
did you find out which all files are excluded when its ran from crontab??
  #5 (permalink)  
Old 04-10-2009
digitalrg's Avatar
digitalrg digitalrg is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 26
Thanks vidyadhar ... Out of 200 directoried its is just able to tar 4 directories...it is stopping at folder by name trasaction with transactioid.txn files One more thing is that if i manually untar the 38 Mb back up i am getting an error
-rw-r--r-- www-data/root 61434 2009-01-29 19:07 repos/subversion/flightops/db/revs/2021
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
this will not come while untaring the 2.8GB tar file. It untars it without any issues...
Thanks..
  #6 (permalink)  
Old 04-10-2009
choogendyk choogendyk is offline
Registered User
  
 

Join Date: Jan 2009
Location: Massachusetts
Posts: 41
For one thing, I would not use the `. /path/to/script` syntax. Put a first line in the script that says "#!/bin/ksh" or "#!/bin/bash" or whatever shell you use in your user environment. Then use `/path/to/script` as the syntax. That will at least ensure that your shell is the same in both user environment and cron.

You want to be looking for what might be different in the two environments.

For the moment, I assume we can ignore the scp, since you are not even getting the full tar file. Maybe comment out the scp and see what happens from cron.

Maybe add a line right after the tar line that does `echo "return code $?";`.

You don't get any output email from cron? (What it would do if an error message or other output was generated).
  #7 (permalink)  
Old 04-13-2009
digitalrg's Avatar
digitalrg digitalrg is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 26
Thanks Choogendyk,
I placed #!/bin/bash, changed the `/path/to/script`, commented SCP and also i put in the return core it says " return code 2 "but no tar file has been created.. i dont know how to setup mail in Ubuntu... hep plz...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0