I posted a question yesterday for help with a perl script and got a solution but it didn't work right in the test environment for me.
Here's what the script does.
It takes a file (filenameYYMMDD) and looks at the time it was modified. than compares that time with the local system time. If the time is greater than 15 minutes than it throws an error message. if it has been modified within the last 15 minutes than it just quits.
Here's the code that I've...
#!/usr/bin/perl
use strict;
use warnings;
use POSIX 'strftime';
#File name
my $FileNameBase = '/export/home/test/test080
423';
#File name with YYMMDD added - I commented this out because the file already has MMYYDD at the end
#my $FileName = $FileNameBase . strftime('%y%m%d', localtime());
#Get last modified time for file
my $FileLastModTime = (stat($FileNameBase))[9];
#Get difference from system time to file last modified time
my $FileTimeDiff = time() - $FileLastModTime;
#Exit if file is newer than 15 minutes
exit unless $FileTimeDiff > 15*60*60;
#Error Message
$a = 'Didnt work';
print $a;
The script doesn't throw an error even if the file has not been modified within the last hour...I need it to throw an error if it hasn't been modified within the last 15 minutes....
Any advice?
Thanks,
inazir
Start Free Trial