-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcleanQueue.pl
More file actions
executable file
·41 lines (30 loc) · 822 Bytes
/
cleanQueue.pl
File metadata and controls
executable file
·41 lines (30 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl
use strict;
#my $queueDirs = $ARGV[0];
#my (@dirs) = split (/\s+/,$queueDirs);
foreach my $dir (@ARGV) {
chdir $dir or die ("Cannot chdir to $dir");
my $week = 7*24*60*60;
opendir INDIR, "." or die ("Cannot open dot");
my (@allFiles) = readdir (INDIR);
closedir INDIR;
my $currentTime = time;
my $rmCount = 0;
foreach my $file (@allFiles) {
if ($file =~ /^ask\.msg\./) {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($file);
if ($mtime < $currentTime - $week) {
#print "rm $file\n";
unlink ($file) or die ("Cannot unlink $file");
$rmCount++;
} else {
#print "keep $file\n";
}
} else {
#warn "$file does not match\n";
}
}
print "$dir: removed $rmCount files\n";
}