Here is a perl script that I wrote a while back that keeps track of how
many days it has been since a user has checked there mail. This could
be useful for what you are trying to do. You will need to change the
variable $file to be a file that can be created on your system. This
script is designed to run nightly, after the popper.log has been
rotated. You can then process the $file whenever you want to delete
mailboxes that haven't been used after a certain period of time.
[--snip--]
#!/usr/local/bin/perl
########################################################################
##
##
## For Sunset Net LLC
##
## Program Name: last_pop.pl
## Programmer: Justin Ainsworth ([EMAIL PROTECTED])
## Date: May 24, 2001 @ 10:50pm
##
##**********************************************************************
**
##
## Filename: last_pop.pl
## Description: Generates a list of users who didn't pop there
## mail yesterday.
##
## ChangeLog:
##
########################################################################
##
use strict;
my $DEBUG = 0;
my %LAST;
my %USERS;
my %SYSTEM_ACCOUNTS;
my $file =
"/usr/local/bin/sunset-scripts/maintenance/non_popping_users";
# Get a list of all CURRENT users
my @TMP = `cat /etc/passwd | /usr/bin/cut -d: -f 1`;
chomp(@TMP);
foreach my $line (@TMP){
$USERS{$line} = 1;
}
@TMP = `cat /etc/systemaccounts`;
chomp(@TMP);
foreach my $line (@TMP){
$SYSTEM_ACCOUNTS{$line} = 1;
}
# Find out how long it has been since they last popped there mail
if( -f $file){
open(LOG,$file);
my @TMP = <LOG>;
chomp(@TMP);
close(LOG);
foreach my $line (@TMP){
my($user,$num_days) = split(/:/,$line);
if($USERS{$user}){
$LAST{$user} = $num_days;
}
}
}
foreach my $key (keys(%USERS)){
if(!$LAST{$key}){
$LAST{$key} = 0;
}
}
# Increment everyone up one day
foreach my $key (keys(%LAST)){
if(-f "/usr/cust/$key/.forward"){
} elsif ( -f "/usr/cust/$key/.procmailrc" ){
} else {
$LAST{$key} = $LAST{$key} + 1;
}
}
my @TMP = `/bin/gunzip -c /var/log/popper.log.1.gz | /bin/grep -v
127.0.0.1 | /usr/bin/cut -d' ' -f 7 | /bin/sort | /usr/bin/uniq`;
chomp(@TMP);
# Everyone who checked mail yesterday get set to 0
foreach my $line (@TMP){
$LAST{$line} = 0;
if($DEBUG){
print "$line\n";
}
}
# All system accounts get set to 0
foreach my $key (keys %SYSTEM_ACCOUNTS){
$LAST{$key} = 0;
}
if($DEBUG){
foreach my $key (sort(keys %LAST)){
print "$key:$LAST{$key}\n";
}
}
open(FILE,">$file");
foreach my $key (sort(keys(%LAST))){
if($LAST{$key} != 0){
print FILE "$key:$LAST{$key}\n";
}
}
close(FILE);
[--Snip--]
.~.
/v\
-- // \\
JA /( )\
^`~`^
L I N U X
[-----------------------------------------------------------]
Justin Ainsworth Systems Administrator
PHONE: (530) 879-5660x108 Sunset Net LLC
FAX: (530) 879-5676 1915 Mangrove Ave
WEB: http://www.sunset.net Chico, CA 95926
EMAIL: [EMAIL PROTECTED]
[-----------------------------------------------------------]
> -----Original Message-----
> From: Alan Brown [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 19, 2002 12:21 PM
> To: Gregory Hicks
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Scripts for analying POP3 usage
>
>
> On Thu, 19 Sep 2002, Gregory Hicks wrote:
>
> > Sometime ago, someone supplied a pointer to 'preenmail'.
> That allows
> > you to specify a date 30, 60, 90, whatever days ago and to
> delete all
> > mail older than that date.
>
> The problem with doing that is that it also finds mail the
> user has left on server, so if you're wanting to track
> dead/abandoned accounts it causes problems of its own by
> updating the folder stamp. It's primarily intended as a way
> of enforcing serverside (don't store) storage policies.
>
> As far as the backup program mentioned by another poster
> goes, there should be a flag to not tweak atime/mtime/ctime
> stamps on files being backed up.
>
>
> As per usual, there are a dozen different ways of killing
> this cat, all with their own advantages and disadvantages.
> Thankfully we're not all at each others' throats about how to
> do this. :-)
>
> AB
>
>
>