[Dovecot] replacement for IMAP_EMPTYTRASH=Trash:7

Ed W lists at wildgooses.com
Fri Feb 8 18:53:35 EET 2008


Hi

> Therefore, i wrote a script that dives into the user's directories and their 
> maildirs. It looks like this

Just for reference I actually read the find manual one evening and 
figured out the syntax (wahey!), then 10 mins later had forgotten it all 
again...

However, in the intervening mins I wrote this little script (watch out 
for line breaks, find command should all be on one line).  The -ls just 
means that I can see it working and for debugging it means that at least 
you can spot if it's gone off the rails... Remove the -ls and stick it 
in cron when you are happy (obviously fix the start dir in this script 
though....)

#!/bin/bash
find .  \( -wholename "*/.Spam/cur/*" -type f -mtime +7 -delete -ls \) , 
\( -wholename "*/.Spam/new/*" -type f -mtime +7 -delete -ls \) , \( 
-wholename "*/.Trash/cur/*" -type f -delete -ls \) , \( -wholename 
"*/.Trash/new/*" -type f -delete -ls \)

I think the issue with mtime is that it gets reset when users open a 
folder and mail moves from /new to /cur ?

Incidently here is a recipe to clean up large Sent Items folders... Use 
with caution...  It demonstrates finding files based on size, date and 
also excluding one folder from being pruned...

find . \( -wholename "*/.Sent\ Items/cur/*" \! -wholename 
"*/exclude_this_user/*" -type f -mtime +30 -size +5M  -ls -delete \) , 
\( -wholename "*/.Sent\ Items/new/*" \! -wholename 
"*/exclude_this_user/*" -type f -mtime +30 -size +5M  -ls -delete \)

Ed W



More information about the dovecot mailing list