Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SCript problem

Status
Not open for further replies.

Midrange

Vendor
Aug 28, 2002
135
SG
Hi there, i have created a script and it was working fine before. But now strange things are happening.

the data on the /backup/A filesystem are also being written to all the filesystems.

But when i run the script interactively, it works normal.

Hoping for your quick response.


BACK_TIME=`date +"%Y%m%d"`
LOCAL_DIR_A=backup/A
LOCAL_DIR_B=backup/B
LOCAL_DIR_C=backup/C
LOCAL_DIR_D=backup/D
LOCAL_DIR_E=backup/E

echo "\nRun Date and Time:" >> /tmp/$BACK_TIME.log
date >> /tmp/$BACK_TIME.log

# Procedure 1. For A Filesystem

cd /$LOCAL_DIR_A/$BACK_TIME;
find . -print |cpio -pdlmv /A

# Procedure 2. For /B Filesystem

cd /$LOCAL_DIR_B/$BACK_TIME;
find . -print |cpio -pdlvm /B


# Procedure 3. For /C Filesystem

cd /$LOCAL_DIR_C/$BACK_TIME;
find . -print |cpio -pdlvm /C

# Procedure 4. For /usr/fiji Filesystem

cd /$LOCAL_DIR_D/$BACK_TIME;
find . -print |cpio -pdlvm /D

# Procedure 5. For /usr/samoa Filesystem

cd /$LOCAL_DIR_E/$BACK_TIME;
find . -print |cpio -pdlvm /E

 
Hi,

Your variable BACK_TIME is set with the day date, so this directory does not exist when you run the script every day.

The command cd /$LOCAL_DIR_A/NONEXISTENTDIRECTORY will not change to the desired location and it stays where it was before.

Mybe your script works interactively because you are positionned in the right location (/backup) before executing the script (the cd stays in /backup and the script bacups every thing under /backup)

If I understand, you want to backup this locations
/backup/A
/backup/B
/backup/C
/backup/D
/backup/E

not this ones

/backup/A/20050405
/backup/B/20050405
/backup/C/20050405
/backup/D/20050405
/backup/E/20050405

Aren't you ?


Ali
 
Hi aau,


Sorry to confuse you. The /backup/A and so on are the source directory and under them had a directory of $BACK_TIME. This directory was generated from the other machine.

So i want to copy the /backup/A/20050405 to /A filesystem (disk to disk copy).

and when i run it interactively, i'm on the / filesystem.

thanks.


 
Hi,
Now, I understand your problem, but how do you execute the script non interactively ?
Is it in crontab ?
Is it whithin another script ?
What kind of strange things are arriving ?

Ali


 
Sounds like it cd's to /$LOCAL_DIR_A/$BACK_TIME
but fails to cd out to /$LOCAL_DIR_B/$BACK_TIME or any of the other directories.
Does the cron user have the relevant permissions on these directories?


"If you always do what you've always done, you will always be where you've always been."
 
I suggest running your script in crontab and directing output to stdout and stderr.

E.g. * * * * * /runscript.sh 1>/tmp/runscr.out 2>/tmp/runscr.err

Then check the output and in this way you'll see if something funny's up in your script. Also you could run your script with "set -vx" to debug each step.
 
HI thanks for all the response.

aau, the script run thru crontab by calling the script (ksh script-name).

rzs0502, the crontab is under root.

Zahier, i will run the script with directing output to stdout and stderr..

 
Hi,

In crontab, be sur you have the complete path to your script even if the script is in your PATH; like this :
00 23 * * 6 /path/to/your/script.ksh 1>/dev/null 2>&1

Ali
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top