[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Delete 4 million files




On Mar 18, 2009, at 1:53 PM, Rob Starling wrote:

On Wed, Mar 18, 2009 at 10:25:13AM -0700, Raquel wrote:
On Wed, 18 Mar 2009 16:37:53 +0000
kj <koffiejunkielistlurker@koffiejunkie.za.net> wrote:
I discovered a Maildir on my server with 4+ million mails in.  The
result of a cronjob that runs every minute - this has been fixed.

Now, I've been running the usual find . -type f -exec rm {} \;
but this is going at about 700,000 per day.  Would simply doing an
rm -rf on the Maildir be quicker?  Or is there a better way?

Why not # cd $Maildir
then # rm -R *

don't do that; that's asking the shell to expand '*' and then
pass the list (4+ million items!) to 'rm'.  it'll either truncate
the list (and you'll have to run it several times), or it won't
run at all (complaining of 'argument list too long')

My experience is that rm will return with "argument list too long" as you say.

I have some log directories and every now and then, for some dumb reason, I end up disabling the program that removes old logs as needed and have to do it myself. I don't know the limit of files it'll handle, but I've had to use wildcards that will eliminate most files. I've done things like "rm -f 2009-03-0*" for all files in the first ten days of March and found that was still to long and had to do it for each day. Other times I've done "rm -f a*" in directories and stepped through the alphabet that way.

If there's some way to limit the files rm sees at a time with wildcards and subdirectories, that might be the best bet.


Hal


Reply to: