Operating System - Tru64 Unix
1828770 Members
2814 Online
109985 Solutions
New Discussion

Re: cp files based on newer date

 
SOLVED
Go to solution
Keith_107
Occasional Contributor

cp files based on newer date

I have multiple Tru64 v5.1a servers and over the years have developed numerous shell scripts. To make a long explanation short, I sometimes lose track of which server has the latest version of a script and have copied over the newer version with an older version.

What I'm looking for is a way to write another script that will only copy (overwrite) the destination file if the file date of the source is newer. I don't see where the Tru64 cp command has this capability and I also don't see a practical way to compare the file dates of source and destination to determine if the cp command should proceed.
2 REPLIES 2
Stuart Fuller_2
Valued Contributor
Solution

Re: cp files based on newer date

Tru64 comes with a tool called "nrdist" (New rdist). You create a config file, indicate one or more lists of hosts, one or more lists of files, and commands to distribute the files to the hosts.

nrdist only works with nrdist on the other hosts. If the other hosts aren't Tru64 (like, Solaris, for example), there's also "rdist". It's similar, but with a few less features.

Set up the config file, try it out, then put in a crontab entry to run nightly.

They both work great; we use them every night.
Ross Minkov
Esteemed Contributor

Re: cp files based on newer date

Sometimes I use the find command to solve similar problems:

From find(1):

-newer file
TRUE if the current file was modified more recently than the file indicated by file.

Or... Is it a problem if you just overwrite the script with the latest version say every day, just to make sure that you have the latest?

-Ross