Re: compare file dates across nodes

From: Bill Thompson (bill.thompson@GOODYEAR.COM)
Date: Mon Aug 04 2003 - 11:41:55 EDT


Shawn,

I think you have to roll your own on this.

Here's a simple Perl script that will display the timestamp of a file in
epoch format:

- - - - - snip - - - - -
#!/usr/bin/perl
die "usage: $0 filename\n" unless ( scalar(@ARGV) == 1 );
die "file $ARGV[0] does not exist\n" unless ( -f $ARGV[0] );
printf "%d\n",(stat(_))[9];
- - - - - snip - - - - -

Note! In the last line "printf "%d\n",(stat(_))[9];" the "[9]" will return
mtime. Change the 9 to 8 for atime or 10 for ctime.

You can run this script against the file on both systems and compare the
results.

e.g.:
LOCAL_DATE=$(/full/path/script /full/path/filename 2>/dev/null)
REMOTE_DATE=$(remsh nf1n01en1 /full/path/script /full/path/filename
2>/dev/null)

HTH

Bill Thompson
Sr UNIX Systems Administrator
The Goodyear Tire & Rubber Co.

Contains Confidential and/or Proprietary Information
May Not Be Copied or Disseminated Without Express Consent of The Goodyear
Tire & Rubber Company.

AIX-L Archives: http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2

----- Original Message -----
From: "Shawn Bierman" <BiermanS@METHODISTHEALTH.ORG>
Newsgroups: bit.listserv.aix-l
To: <aix-l@Princeton.EDU>
Sent: Monday, August 04, 2003 10:21 AM
Subject: compare file dates across nodes

> Is it possible to script this function? I would like to get the date of
a file on a remote node ( with rsh ) and compare it to the date of a file
on my local box. If its newer than the local file then do something if not
do something else...kind of thing.
>
> without having to do something like: rsh nf1n01en1 ls -l
/mksysb_dir/bos.obj.nf1n01en1.31Jul03| awk '{print $6 $7}'
>
> which returns: Jul31
>
> is there a command that can get the date of a file and return it in
numeric form or something?
>
> this is aix5.1
>
> -shawn



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:07 EDT