Date: Fri, 14 Jul 2000 22:01:51 +0200 From: Bart Lateur <bart.lateur@skynet.be> To: FreeBSD-Questions <freebsd-questions@FreeBSD.ORG> Subject: Re: any faster way to rm -rf huge directory? Message-ID: <h1rums4753p3vgg5i50cec8lfj08ffkh49@4ax.com> In-Reply-To: <v04210107b5940173ffad@[128.113.24.47]> References: <Pine.BSF.4.21.0007131356240.65575-100000@harlie.bfd.com> <v04210107b5940173ffad@[128.113.24.47]>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 13 Jul 2000 19:40:21 -0400, Garance A Drosihn wrote: >Is it easy to tell which order the files were added to the >directory? (easy to tell by the filename, I mean. It'd be >murder to have to stat() each file to find out the order!). >I wonder if it would speed things up at all if you could >remove the files in the opposite order of the order they >were created in. I'd expect the opposite, i.e. that it would be faster if you deleted them in the same order they were created. Now, the reason it takes so long to delete a file (a few seconds) is simply because each file has to be looked up by name, which can take a while if there are 1/4 million files. Now, if you can make sure each file is found faster rather than slower, the whole deletion would take less time. Now, how can you do that? In a perl script, do opendir(). Then do readdir(), which will return the first file found. Probably this is the oldest file (if no files were created after older files were deleted). Delete it. This should be pretty fast. Do readdir() again, and you get the next file. Etc... until all are done. Well, I would hope this would work a lot faster than deleting then in, say, alphabetical order. Hope. -- Bart. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?h1rums4753p3vgg5i50cec8lfj08ffkh49>