[ale] best solution for removing large # of files on NFS share.

Jim Kinney jim.kinney at gmail.com
Wed Jun 29 13:08:52 EDT 2022


Having been bit by rm before, I now do a mv oldname newname on the dir to be removed and let it sit for a day or more to see who screams. Same process works in a dir to create a new dir called delete-me and mv the files into delete-me. Do a cleanout later after user screams subside.

I only care about my efficiency. The computer exists to do my bidding. It's nice to not eat up resources on SA stuff, but if it takes "too long" to implement, my time is more valuable.

On June 29, 2022 12:27:43 PM EDT, Bob Toxen via Ale <ale at ale.org> wrote:
>Efficiency is very close since neither involves a fork/exec sequence
>(which is very expensive).
>Do whichever you are most comfortable with.
>
>Since I am very paranoid about "rm -rf" in case of mistyping, I might
>use the find
>with a -name thusly:
>
>  find dir1 -type f -name '*.stupid_log_file_ext' -delete
>
>I might add before the -delete and put in root's crontab:
>
>  ! -mtime +365
>
>The "find" certainly needs to do a "stat()" system call which has a
>slight overhead.
>However, the "rm -rf" almost certainly has do a "stat()" as well to
>determine if
>each file is a directory (that requires a "rmdir()" system call instead
>of an
>"unlink()" system call.
>
>The "rm -rf" might be smart enough to just do an "unlink()" call and if
>it
>returns the error EISDIR (error it is a directory) it then would
>recursively
>delete the files and dirs in that dir and then do an "unlink()" call.
>
>In either case each file's (and dir's) inode would need to be read off
>of
>disk to know the disk blocks to put on the free list.
>
>Bob
>
>On Wed, Jun 29, 2022 at 11:18:24AM -0400, Geoffrey Myers via Ale wrote:
>> Looking for some advice for the best way to delete a large number of
>> files spread across a large number of directories on an NFS share. 
>RHEL7
>
>> There are 6 directories of the form:
>
>> dir1/month/day/hour/minute/
>> .
>> .
>> dir6/month/day/hour/minute/
>
>
>> There are only files in the minute???s directories.
>
>> which is a more efficient solution?
>
>> 1.	find dir1 -type f -delete
>> 2.	rm -rf dir1
>
>
>> Regarding #2, the directories will be recreated by the application.
>
>> --
>> Until later, Geof
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> https://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>_______________________________________________
>Ale mailing list
>Ale at ale.org
>https://mail.ale.org/mailman/listinfo/ale
>See JOBS, ANNOUNCE and SCHOOLS lists at
>http://mail.ale.org/mailman/listinfo

-- 
Computers amplify human error
Super computers are really cool
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.ale.org/pipermail/ale/attachments/20220629/a8e9d8b6/attachment.htm>


More information about the Ale mailing list