File Time Comparison Question

I want a cron job to fire off every 5 minutes or so to verify that a
file in a directory is not more than 15 minutes old (from the current
time. If the newest file is more than 15 minutes old, I would fire
off an email..

The email part is easy, but I'm having trouble figuring the logic
behind the comparison..

Any thoughts?

Hi,

I knew I'dd seen this question before.
The thing is that the command "find" will only count per day (24 hours), so therefor you'dd make a refference file :

touch -amt 07231951 /tmp/ref

And use the -newer option from find :

find /tmp -newer /tmp/ref

If it results anything you know it's older, right ?

Also a perl-script could help you out a bit. You should do some work still, thought :slight_smile:

#!/opt/perl/bin/perl

$filename = "$ARGV[0]";

@s = stat($filename);

$atime = localtime($s[8]);
$mtime = localtime($s[9]);
$ctime = localtime($s[10);

print "Time of the last access (atime) = $atime\n";
print "Time of last inode change (ctime) = $ctime\n";
print "Time of the last modification (mtime) = $mtime\n";

@yourservice
David

Thanks for your responce.