<<< Date Index >>>     <<< Thread Index >>>

Re: Automatically Deleting old Messages



On or about Tue, Jul 31, 2007 at 07:44 -0500, Matt Okeson-Harlow had this to 
say:
> On Tue, Jul 31, 2007 at 03:27:42PM +0200, Louis-David Mitterrand wrote:
> > On Fri, Jun 15, 2007 at 11:56:41PM +0300, tyler.roach@xxxxxxxxxxxxxx wrote:
> > > Hi,
> > >    Is there any way I can make mutt (or another application)
> > >    automatically delete messages in _certain_ folders (such as mailing
> > >    lists) that are over a certain number of days old?
> > 
> > If you have a unix account on your mail server then you can enter these 
> > crontab jobs:
> > 
> > ## remove all list mails older than 60 days in folders matching 
> > ## ~/Maildir/.[a-z]* and ~/Maildir/.Admin.*
> > 0 2 * * * find /home/ldm/Maildir -mindepth 3 -maxdepth 3 -type f -mtime +60 
> > \( -path '/home/ldm/Maildir/.[a-z]*' -o -path '/home/ldm/Maildir/.Admin.*' 
> > \) -exec rm -f {} \;
> > 
> > ## remove all empty maildirs
> > 0 3 * * * for i in ~/Maildir/.*; do if [ -d "$i" ] && [ ! "$(find "$i" 
> > -mindepth 2 -type f)" ]; then rm -rf "$i" ; fi ; done
> > 
> > (thanks to greycat on #bash for help on these)
> 
> Another option would be to use the 'archivemail' utility.
> 
>     http://archivemail.sourceforge.net/
> 
> It even works over IMAP.
> 
> For instance:
> 
>     /usr/bin/archivemail -q -d 15 ~/Maildir/.Trash
> 
> Will [-q] quietly archive mail older that [-d 15] 15 days.  To have it delete
> instead of archive, add the --delete switch.
> 
> -- 
> Matt Okeson-Harlow
> Sen gutoj malgrandaj maro ne ekzistus

I use folder hooks such as the following to delete old mail:
folder-hook mutt-users 'push D~d>20d.\n'

In this case it always keeps 20 days of messages in the folder and deletes all
that are older.  

Gerry