From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Thread: fa528,d86f44c2176449dd X-Google-Attributes: gidfa528,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: panzerboy@gmail.com (Jeremy Thomson) Newsgroups: comp.unix.tru64 Subject: Re: Efficient way of deleted large directories Date: 26 Sep 2004 15:50:18 -0700 Organization: http://groups.google.com Message-ID: <6425a413.0409261450.32929225@posting.google.com> References: <6425a413.0409221716.55a1cb5@posting.google.com> <6425a413.0409231459.564df263@posting.google.com> NNTP-Posting-Host: 210.55.211.10 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1096239018 477 127.0.0.1 (26 Sep 2004 22:50:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 26 Sep 2004 22:50:18 +0000 (UTC) Xref: g2news1.google.com comp.unix.tru64:318 Bob Harris wrote in message news:... > In article <6425a413.0409231459.564df263@posting.google.com>, > panzerboy@gmail.com (Jeremy Thomson) wrote: ... > > Finally got the directories deleted, probably took about 20 hours over > > a couple of days. > > That was two directories with 518,000 and 528,000 files respectively. > > The last way I tried deleteing was ls -1r | xargs -i rm -f {} > > That seemed a little bit faster though by that time there was only > > 200,000 files to delete, so I guess it would have been faster anyway. > > I think that /bin/ls -1r would just change the name sorting order, but I > do not think it would cause an lstat() operation. And since you have > index files, there is not as much benefit to removing the files in a > specific order. But if you want to squeeze out very last drop of > performance, then I think > > /bin/ls -1f directory | xargs rm -f > > would be about as good as it gets. You might squeeze a few tiny drops > out of writing your own C program to read the directory using readdir() > and call remove(). That would eliminate multiple invocations of the rm > command, but the xargs command does bunch up the files so that it does > not need to invoke rm too many times. I think ls -f into xargs is good > enough. > > > regards, > > Jeremy Thomson > > I don't know what the files in the huge directory(s) are used for, if > you have a way to pruning them on a regular basis, say via a cron job, > it might help with the sudden load demand to do this before the vdump. > > Bob Harris The data isnt at all important, one is a log of the output of UniData phantom processes, the other captures of SQL enquiries. We only look at this stuff if something goes wrong. We do have a regular cron'd purge, it was the failure of this that started the whole problem. I had a c program that would compare list of filenames and a cutoff date and output the filenames modified earlier than the cutoff so they could be deleted. It fell over when it couldnt stat() a file. Unbeknownst to me temporary files were being put in one of the directories then renamed. That broke the purge.