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

Re: Delete 4 million files

On Mar 19, 2009, at 1:38 AM, Paul E Condon wrote:

On 2009-03-18_16:37:53, kj wrote:
Hi guys,

This might seem like a stupid question, but I'm hoping there's a better way.

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?



I presume there is a single directory entry that is root to the portion of your file system where these files reside. I further presume that ALL the
files in this portion of the file system should be deleted. For this,
supposing the the name of the root is 'foo' and the path to 'foo' is 'bar'
the command to use is
rm -rm /bar/foo
NOt some fiddle using 'find'.

Better than the "rm" command, above, I suggest:

Create a path, on the same disk to a place called 'hide', and
mv /bar/foo /hide
rm -rf /hide/foo &

This moves the junk emails to a place where they are not visible to
normal activities on the system. Then starts the 'rm' job in the
background so that you can use the console for other activities while
the job is running. You can monitor the progress of the job by
running 'df' when you are curious about how much progress has been
made. I suggest 'lost+found' as a good choice for 'hide'.

Won't this run into a problem with the infamous "argument list too long" response from rm that we've been talking about once it descends into the subdirectories?

Or is there some reason it wouldn't?


Reply to: