On Sat, 15 Mar 2003 09:44 +0100, Narrowstream wrote to Subscribers of
Qpopper:

> I want to know when the users check their mailbox because, if they don't
> check, it means they don't need and then, I can remove the mailbox :) I use
> a script to check the date of the .user.cache file.

You don't need the .user.pop file for that.  On most systems you can
determine when a customer last read mail by the ATIME (last access time)
of the mailbox (/var/mail/username or whatever).  If you don't have many
mailboxes, use `ls -laut /var/mail' to generate a list sorted by last
access time.  To determine how long it has been since a specific user
accessed his/her mail, use `ls -lau /var/mail/username'.

If you have a lot of mailboxes the `ls' output will be too unweildy.
Instead, use `find /var/mail -atime +30' to generate a list of mailboxes
that haven't been accessed in the past 30 days.  Substitute your preferred
number of days.

To delete all mailboxes that have not been accessed in the past 30 days,
use `find /var/mail -atime +30 -print -exec rm {} \;' .  That will list
each offending mailbox, then delete it.

To automate the process, run something like this script as a cron job once
per day.

------------------------
#!/bin/sh
#
# Delete mail spool files that have not been accessed
# in the past 30 days. If someone doesn't read his/her
# e-mail at least that often, we assume he/she doesn't
# care about e-mail. The "echo" lines and the "-print"
# argument in the find command causes cron to mail
# output to root, giving us a daily list of users whose
# mail has been deleted.
#
# cron runs this at midnight every night and e-mails the
# output to root.
#
echo "***** DAILY MAILBOX PURGE ****"
echo " "
echo "The following mailboxes have not been accessed by their"
echo "owners in the past 30 days.  If a user does not read"
echo "his/her e-mail at least that often, we assume he/she"
echo "is not interested in e-mail, so we delete the mailbox."
echo " "
echo "These mailboxes have been deleted:"
echo " "
find /var/mail -atime +30 -print -exec rm {} \;
-----------------------

Cron will mail the output to the root mailbox.  Save these messages for
some amount of time, so if a custome screams "where did my mail go" you
can explain what happened, when it happened, and why it happened.

WARNING:  If you delete mailboxes that haven't been accessed in n days (or
for that matter if you manipulate or modify mailboxes in any way for any
reason), make sure your customers know and accept the fact that this is
your policy.  Otherwise I guarantee you'll have a lynch mob after you.

-- 
Chip Old (Francis E. Old)             E-Mail:  [EMAIL PROTECTED]
Manager, BCPL Network Services        Phone:   410-887-6180
Manager, BCPL.NET Internet Services   FAX:     410-887-2091
320 York Road
Towson, MD 21204  USA

Reply via email to