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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with modification times.

Status
Not open for further replies.

millsra

MIS
Jun 25, 2002
43
0
0
US
Ok here is what I am trying to do.

I need to SCP files from one server to the other at intervals. As I send the files I am going to append a file with the filenames of everything that I send. (This is only for a 2 day migration) Archive logs are what I am sending. As the files are sent more files are going to be created so I need to be able to have a way to compare what has been sent to what needs to be sent. The other problem I have is I can not send the current file that is being updated.


I thought I could use something like.

find . -newer files_sent -print>files_to_be_sent

The problem that I am worried about is what happens if a file is completed while a file is being sent. How do I keep from missing a file. There has to be another way to do this that is still effecient. Anyone who has something that I could use would be great. I know this is probably easy for you seasoned scripters. I stumble through scripts since I mainly do Storage.


Thank you in advance

 
How about two directories - pending and sent so
Code:
#/bin/ksh
typeset -A files $(ls -tr)
COUNT=0
while [[ $COUNT -lt ${files[*]} ]]
do
  scp $files[$COUNT] remote_host:/remote_dir
  mv $files[$COUNT] processed_dir
  (( COUNT += 1 ))
done
Because we're testing COUNT as less than ${files[*]} it won't send the latest file. This ensures that you won't send any file being processed (although you'll never have the latest file). Moving the processed files to another directory means you can use ls -tr to list the one's to go.

Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top