[CentOS] Maildir Cleanup

Wed Jan 31 22:26:46 UTC 2007
mouss <mlist.only at free.fr>

Jun Salen wrote:
> Hi all,
>
> I found an article (with python script) on how to
> clean up Maildir folder
> for  old email messages from
> http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old-mails/
>  . As I understand, this will be run by each user
> after login. How can I make this runs at least once a
> month and
> delete all users message with age more than one month
> for example using crontab? I am using Postfix,
> MailScanner, SpamAssassin, Courier IMAP/POP3, ClamAV
> and CentOS4.4 as mail server. If you need further
> input, please just let me know. Thanks in advance for
> help. Thanks. 
>   

to run the script monthly, put it in /etc/cron.monthly. but you can also 
run it daily or weekly (but only delete files with age > 1 month).

Instead of deleting, consider moving the files to some place to give you 
time to recover should something bad happens...

<untested>

maildir_list=....
for _maildir in $maildir_list; do
  for d in `find $maildir -type d -name cur`; do
    find $d -type f -ctime +30 -exec rm {} \`
  done
done

</untested>

</untested>