Re: Fastest way of removing very large number of files?

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



In article <20130823104855.GA15299@xxxxxxxxxxxxxxxxxx>,
Stephen Harris <lists@xxxxxxxxxx> wrote:
> On Fri, Aug 23, 2013 at 12:40:51PM +0200, Dennis Jacobfeuerborn wrote:
> > I doubt saving functions calls is going to gain you anything in this 
> > case as 99.9% of the time the rm takes is on disk I/O. If you want to 
> > reduce the rm time you have to find a way to reduce the disk I/O it 
> > requires.
> 
> Correct.
> 
> If it's a whole directory (tree) that needs removing then I find
> 
>   mv dir dir.o ; mkdir dir ; chown ##:## dir; chmod ### dir ; rm -r dir.o &
> 
> type stuff works just fine; the rm can chunk along in the background
> while there's now a nice clean empty directory for the application.

You can even dispense with the ## variable parts. And I would get the owner
and modes correct before making the new directory appear:

mkdir dir.n && chown --reference=dir dir.n && chmod --reference=dir dir.n && \
mv dir dir.o && mv dir.n dir && echo rm -fr dir.o \; echo dir.o deleted | batch

That will do the removal in a batch job without hanging on to the tty, and
will email you a quick note (the output from batch) when it's done.

Cheers
Tony
-- 
Tony Mountifield
Work: tony@xxxxxxxxxxxxx - http://www.softins.co.uk
Play: tony@xxxxxxxxxxxxxxx - http://tony.mountifield.org
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux