Here is an updated version of my perl program to handle the find cleanup 
parts of qmail-scanner-queue.pl -z.   The first version, if the 
/var/spool/qmailscan directory had not been updated in a day, went ahead 
and deleted it as well.   

====
#!/usr/bin/perl

# This program will remove all files in the qmailscan directory older 
# older than one day, except in the quarantine and archive directories,
# or if the file has a .log, .txt , or .db extension.
# Version 1.01, [EMAIL PROTECTED] 2003/09/23

use strict;
use File::Find;
use File::Path;

my $currenttime = scalar time();

sub cleanup_files {

        my $file=$File::Find::name,"\n";
        # Skip if it matches things we want to keep.
        next if -l $file;
        next if $file =~ /quarantine/;
        next if $file =~ /archive/;
        next if $file =~ /\.log/;
        next if $file =~ /\.txt/;
        next if $file =~ /\.db/;
        next if -d $file and $file =~ /working/;
        next if -d $file and $file =~ /qmailscan\Z/;
        # Subtract current time from file's mtime.
        my $timediff = $currenttime - (stat($file))[9];
        # Skip if less than a day old.
        next if $timediff < 86400;
        # Uncomment for debugging.
        print "$file $timediff \n";
        if (-d $file) {
        rmtree  ($file) or warn "Couldn't rmdir $file: $!";
        } else { 
        unlink ($file) or warn "Couldn't unlink $file: $!";
        }       
} 

finddepth(\&cleanup_files, '/var/spool/qmailscan/');
====

--
Jason


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Qmail-scanner-general mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general

Reply via email to