Hello,
This is my first script in Perl. I have to clear a folder on Windows 2003 server for files (logfiles) older than 14 days. The remove could be based on the system timestamp of the file of on the filename because the filename like:
DailyMpgateway.log.2005-09-15
For that I do this little just to print the files but I don't know how to glob files only for the last 14 days:
#!C:/Perl/bin/perl.exe -w
use Win32;
# Print the directoy where the perl script start;
$currpath = Win32::GetCwd();
print "Cuurent directory is $currpath \n";
# Changing directory and printing the current folder
chdir("c:/dev/perl/LOG") || die "cannot cd to C:\dev\perl\LOG ($!)";
$currpath = Win32::GetCwd();
print "Successfully changed to folder: $currpath \n \n \n";
@all_logs = glob("DailyMpgateway.log.*");
print "List of Logs present on folder: \n";
foreach (@all_logs) {
next unless -f;
next unless -r;
$age = -M;
print "Log: $_ Date: $age \n";
}
Thanks for your help !
This is my first script in Perl. I have to clear a folder on Windows 2003 server for files (logfiles) older than 14 days. The remove could be based on the system timestamp of the file of on the filename because the filename like:
DailyMpgateway.log.2005-09-15
For that I do this little just to print the files but I don't know how to glob files only for the last 14 days:
#!C:/Perl/bin/perl.exe -w
use Win32;
# Print the directoy where the perl script start;
$currpath = Win32::GetCwd();
print "Cuurent directory is $currpath \n";
# Changing directory and printing the current folder
chdir("c:/dev/perl/LOG") || die "cannot cd to C:\dev\perl\LOG ($!)";
$currpath = Win32::GetCwd();
print "Successfully changed to folder: $currpath \n \n \n";
@all_logs = glob("DailyMpgateway.log.*");
print "List of Logs present on folder: \n";
foreach (@all_logs) {
next unless -f;
next unless -r;
$age = -M;
print "Log: $_ Date: $age \n";
}
Thanks for your help !