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

Re: Automatically Deleting old Messages



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)