I�m implementing a failoverconcept. This requires to synchronize two files using ksh like this.
if HOST1:FILE1 is newer then HOST2:FILE1
THEN cp HOST1:FILE1 HOST2:FILE1
ELSE cp HOST2:FILE1 HOST1:FILE1
fi
How can I compare the files on two boxes?
I tried it on one box and it works
and im able to get the date information with ls -l and awk - like this but how i schould compare the datestrings or how can i change the variable format?
I think this will meet my expectations, but due to internal guidelines we�re not allowed to use OpenSource.
SO I only can use the SOLARIS tools or programs delivered by SUN.
There are several problems with doing this via ls. The first is that ls switches formats for old files add shows just the year. All we can do if a case like that is guess as to time. And if it is showing the time, you can just assume the year is the current year because files dated late last year will not have switched formats to show the year. And Solaris adds a problem in that it allows long user names and group names but if you them, the fields in ls overflow and run together.
Here is a script that does the best that can be done under the circumstances: