auto delete email in mailbox

Chris Purcell redhat at cjp.us
Mon Mar 29 16:42:45 UTC 2004


>>> We are using the stock Sendmail and all mail is stored in the
>>> /var/spool/mail directory under individual mailboxes as the name of
>>> the login on the server.  Basically we made no change to it from the
>>> original  installation of RHEL AS.
>>
>>Sendmail uses the mbox format, where each email in a users mailbox is
>> stored in a single text file.  This makes it more difficult to
>> implement what you want to do.  If you switched to Postfix and
>> Maildir-style mailboxes, you could easily write a Perl or bash script
>> that would execute daily via cron to do what you want.  If you want to
>> make the switch, I'll see if I can write it....
>
> If he switches to maildir format, he can use the tmpwatch utility that
> ships with RH. No need to reinvent the wheel.
>
>   tmpwatch --force --mtime age_in_number_of_hours dir

Thats a good idea, but you still need a script that will run this command
in each users ~/Maildir directory.  I prefer using the find command for
this...

/usr/bin/find /path/to/Maildir/ -mtime +15 | xargs rm -f 2&> /dev/null

Chris






More information about the redhat-list mailing list