root/tags/FuzzyOcr-3.4/Utils/fuzzy-cleantmp.pl

Revision 30, 0.7 kB (checked in by decoder, 2 years ago)

Added Development releases 3.4.0 and 3.4.1

Line 
1 #!/usr/local/bin/perl
2 #----
3
4 opendir TMP, "/tmp" or die "Cannot read /tmp\n";
5 my @files = grep {m/spamassassin/} readdir TMP;
6 closedir TMP;
7
8 my $hours = shift @ARGV || 12;
9 my $limit = time - ($hours * 3600);
10 printf "Removing tempfiles older than %s\n",scalar(localtime($limit));
11 foreach my $d (@files) {
12     my $df = "/tmp/" . $d;
13     next unless -d $df;
14     my @stat = stat $df;
15     next if $stat[9] > $limit;
16     printf "$d -> %s\n",scalar(localtime($stat[9]));
17     opendir TMP, $df or die "Cannot read $df\n";
18     my @dfs = readdir TMP;
19     closedir TMP;
20     foreach my $f (@dfs) {
21         next if $f eq '.';
22         next if $f eq '..';
23         my $fn = sprintf "%s/%s",$df,$f;
24         unlink $fn;
25     }
26     rmdir $df;
27 }
Note: See TracBrowser for help on using the browser.