[Dovecot] Need a quick, safe method to empty /home/user/Maildir/{.Junk, .Trash}

Benjamin R. Haskell dovecot at benizi.com
Thu Jun 12 22:52:02 EEST 2008


On Thu, 12 Jun 2008, Kyle Wheeler wrote:

> On Thursday, June 12 at 01:02 PM, quoth Jeff Kowalczyk:
>> On Thu, 12 Jun 2008 10:19:48 -0500, Kyle Wheeler wrote:
>>> If you have a *TON* of messages in those folders (i.e. several thousand), 
>>> your shell may complain that there are too many arguments to the rm 
>>> command. If that happens, these may be better commands to delete them:
>>> 
>>> find /home/user/Maildir/.Junk/cur -type f -delete find 
>>> /home/user/Maildir/.Trash/cur -type f -delete
>> 
>> Thanks, I'm going to do that. And per dmeissler, I'm going to consider 
>> xargs.
>
> <shrug> xargs is good for other things, but if all you're doing is 
> deleting files, find can do it itself without involving other 
> applications. But whatever makes you comfortable.

Not all 'find's are created equal. I think '-delete' is a GNU extension 
(or a relatively new option). It's not in Solaris 8 (Yeah, I know, it's 
old.), for example.


>> Any thoughts on a variant using find -name that could safely iterate over 
>> /home/*/Maildir for all users? Otherwise I would script it in python.
>
> find /home/ -path '*/Maildir/.Junk/cur/*' -type f -delete
>
> ~Kyle
>


More information about the dovecot mailing list