J
Jim
Hi
I have a very simple perl program that runs _very_ slowly. Here's my
code:
#!/usr/local/bin/perl
#
# script to keep only a weeks worth of files
#
use File::stat;
$time = time;
# get list of all files in the backup directory
@files = glob ("/backup/output.log*");
unless (@files[0]) {
print "No files to process\n";
exit;
}
while (<@files>) {
$filename = $_;
$st = stat($_);
$mod_time = $time - $st->mtime;
# if file edit time is greater than x days, delete the file
# 1440 minutes in a day
# 86400 seconds in a day
# 604800 seconds in a week
# 2419200 seconds in a month
# 7257600 seconds in 90 days
if ($mod_time > 7257600) {
print "Deleting file $filename\n";
unlink ($filename);
}
else {
#do nothing
}
}
There are several thousand files (~21K) in this directory and many
thousands of those files fit the criteria to delete. It takes a really
long time to run this program. What's the holdup? Is it glob? My OS
(Solaris 8)? IO? Any way to speed this up? Thanks.
Jim
I have a very simple perl program that runs _very_ slowly. Here's my
code:
#!/usr/local/bin/perl
#
# script to keep only a weeks worth of files
#
use File::stat;
$time = time;
# get list of all files in the backup directory
@files = glob ("/backup/output.log*");
unless (@files[0]) {
print "No files to process\n";
exit;
}
while (<@files>) {
$filename = $_;
$st = stat($_);
$mod_time = $time - $st->mtime;
# if file edit time is greater than x days, delete the file
# 1440 minutes in a day
# 86400 seconds in a day
# 604800 seconds in a week
# 2419200 seconds in a month
# 7257600 seconds in 90 days
if ($mod_time > 7257600) {
print "Deleting file $filename\n";
unlink ($filename);
}
else {
#do nothing
}
}
There are several thousand files (~21K) in this directory and many
thousands of those files fit the criteria to delete. It takes a really
long time to run this program. What's the holdup? Is it glob? My OS
(Solaris 8)? IO? Any way to speed this up? Thanks.
Jim