1833386 Members
3387 Online
110052 Solutions
New Discussion

Re: rcp script

 
SOLVED
Go to solution
Duffs
Regular Advisor

rcp script

Hi,

I have got the following problem with a small rcp script:

rcp `grep -l "^3.*COV" DER*TAR*` <>

As you can see this greps the dir for certain files and rcp's them to serverB.

There is another script cronned on serverB that fetches the files rcp'ed from server A and this is where my problem begins. The other script is cronned for every 5 mins and fetches the files as soon as it sees them resulting in truncated files as the files may not have completed rcp'ing across.

Is there a way of either renaming these files until they have been rcp'ed successfully and then renaming them back or checksuming the actual transfer to overcome this truncation issue????

Cheers
5 REPLIES 5
Doug Burton
Respected Contributor

Re: rcp script

Hmmm... a checksum file sounds like a good idea. Make the file in the begining of the cron/rcp job and toss the files over to server A with the checksum being the last one copied. When done, remove(?) that file (or files) when all target files have finished going over.

On serverB, look for the cheecksum file first, if there your copy is finished. Do want you need to those files and blow away the checksum.
Muthukumar_5
Honored Contributor

Re: rcp script

You can do one simple solution as,

create a file with size and file details of files which are going to be RCPied. RCP this file at last.

Make your cron file to check the specific file contains this details. Your requirement will work correctly if you do like this.

HTH.
Easy to suggest when don't know about the problem!
Kent Ostby
Honored Contributor
Solution

Re: rcp script

Dermot --

I would suggest a lockfile.

The script on machine A does a remshd and touches a file on machine B before it does its "real work".

When its done it removes the lockfile.

The script on machine B checks for the lockfile and wont process anything if the lockfile is present.

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Ermin Borovac
Honored Contributor

Re: rcp script

I suggest program called rsync (rcp replacement).

$ rsync -av -e remsh file1 serverb:/tmp

This will copy file1 to serverb:/tmp/.file1. until file is fully transferred, and only then /tmp/.file1. will be moved to /tmp/file1.

Read more about rsync at

http://samba.org/rsync/
Duffs
Regular Advisor

Re: rcp script

Thanks lads!
Very helpful indeed. Its really a toss up between the 'lockfile' and the 'rsync' solutions; great stuff.
Cheers!