A script doesnt work properly when crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting A script doesnt work properly when crontab
# 1  
Old 04-10-2009
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  
Old 04-10-2009
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  
Old 04-10-2009
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  
Old 04-10-2009
Quote:
Originally Posted by digitalrg
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  
Old 04-10-2009
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  
Old 04-10-2009
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  
Old 04-13-2009
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...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Having trouble getting my interactive perl script to work properly

So I'm making an interactive perl script, but I can't get it to work properly. I'm trying to make a script that tell the user to input either 'q' or 'Q' to terminate the program, or 'c' to continue it. If they input anything other than those three keys, it should prompt the user again and again... (5 Replies)
Discussion started by: Eric1
5 Replies

2. UNIX for Dummies Questions & Answers

[SOLVED] Mv command doesnt work in shell script

Hi All, i created the below script to move file with xml extension from one directory to another,but the mv command is not working inside the shell script, #!/us/bin/ksh filepath="/apps/extract" filename="*.xml" foldername=2191POB000_$(date +%Y%m%d%H%M%S) mkdir -p "$filepath/$foldername"... (3 Replies)
Discussion started by: Radhas
3 Replies

3. UNIX for Dummies Questions & Answers

why doesnt it work?

I am trying to print out two fields in a file using awk. So, I have got awk -F '\t' 'NF = 2 {print $1 $2 "]"}' two.txt in a script called what.awk When i run this version like this - ./what.awk then it runs however I want to run the program like this awk -f what.awk two.txt. When I... (8 Replies)
Discussion started by: The undertaker
8 Replies

4. AIX

Vi doesnt work

Hi Guys, I have a strange problem.( AIX 6.1) "vi" is not working at all..Whenever i #vi <anythin> ,, it returns the prompt back. Any clues folks?? (14 Replies)
Discussion started by: muzahed
14 Replies

5. Shell Programming and Scripting

Script not running properly when run from Crontab

Hi I am a novice Linux/Perl user and am struggling to overcome what I am sure is a simple problem. I am using a perl program to create a shell script daily containing between 10 and 30 "at -f" commands for the same day. Then I change the file attributes to allow the file to be executed. When... (2 Replies)
Discussion started by: simoncjones
2 Replies

6. AIX

Crontab file doesnt seem to work

Hi all. Could anyone explain me why this simple cron job doesnt work: % whoami system % crontab -l * * * * * /usr/bin/touch /home/system/foo (3 Replies)
Discussion started by: bsddaemon
3 Replies

7. UNIX for Dummies Questions & Answers

cp doesnt work - Help

When trying to copy a file in Solaris 8 it doesnt copy file or give a error. This worked 100% until the 29th. I've checked the rights and everything seems fine: drwxrwxrwx 2 bmuser bmgroup 11776 Jan 3 10:32 spool This is the file I want to copy: -rwxrwxrwx 1 bmuser bmgroup ... (26 Replies)
Discussion started by: rudi.okelly
26 Replies

8. Solaris

SSH doesnt exit properly from command line

I ssh to another server and run a few commands - start a few processes that run on the server. I then type exit - by my command line hangs. I have heard that it is waiting until anything processes you are running complete, but these processes are going to run 24*7*365 so obviously I cant wait.... (4 Replies)
Discussion started by: frustrated1
4 Replies

9. UNIX for Dummies Questions & Answers

cd.. doesnt work

hi when i want to go to previous directory by typing cd.. i get the following message $ cd.. ksh: cd..: not found Please help rintingtong (2 Replies)
Discussion started by: rintingtong
2 Replies

10. Shell Programming and Scripting

why doesnt my script work!!!

Is there a utility or command I can use to tell the number of decimal places a number has. For instance, if the number is 432, it will give hundred as the number of decimal places. (7 Replies)
Discussion started by: Heedunk
7 Replies
Login or Register to Ask a Question