Is there anyway to delete a directory that has more than 200mil files?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Is there anyway to delete a directory that has more than 200mil files?
# 1  
Old 06-01-2007
Question Is there anyway to delete a directory that has more than 200mil files?

I have a directory in my server which has grown incredibly huge with high
volume of files. The files were output files generated by the print server.
I'm having problem with removing the files or even the entire directory,
the CPU rate will hit peak whenever I execute the 'rm' command to remove
the files. I also can't do a 'du -sk' of the dir bcos it just hang.

Below is the status of the file when a do a 'ls' from the parent directory :

drwxr-sr-x 2 appltest oradba 204728832 May 30 15:10 log_to_removed

Can anyone help to advise what is the best way to remove or scrape this directory which is taking up space in my server?

Thks,
Patrina
# 2  
Old 06-01-2007
use find to list the files to stdout and then use xargs to execute rm in small chunks....

Code:
find . -print | xargs -n 20 rm

Will delete all the files in the current directory in gulps of 20 at a time.
# 3  
Old 06-01-2007
I just executed the command you gave me, am I supposed to see the listing of files of the stdout? The cursor just blink on the screen, how to confirm that the rm is working?
# 4  
Old 06-01-2007
It's not supposed to print anything on the screen, it's spending all it's time doing it's job. Smilie

use "top" or "ps" to look at process status

You should see "find" and "xargs" working like mad and "rm" with it's pid counting up as each "rm" is run with a group of 20 files.

Also if you do an "ls -ld" of the parent directory you should see the inode reference count dropping as each file is deleted.
# 5  
Old 06-01-2007
Note: You should delete not only the files but also delete and recreate the directory.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete files directory

amigos necesito dejar en un directorio solo los archivos del dia anterio, como puedo hacer eso con una shell Hello. Per our forum rules, all posts must be in English. We do provide translation services for posts from English to a number of languages as a benefit to users. However,... (16 Replies)
Discussion started by: tricampeon81
16 Replies

2. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

3. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurrence of a specific word

he following are the files available in my directory RSK_123_20141113_031500.txt RSK_123_20141113_081500.txt RSK_126_20141113_041500.txt RSK_126_20141113_081800.txt RSK_128_20141113_091600.txt Here, "RSK" is file prefix and 123 is a code name and rest is just timestamp of the file when its... (7 Replies)
Discussion started by: kridhick
7 Replies

4. UNIX for Dummies Questions & Answers

Cannot delete files and directory

hello i am trying to delete some files and also some directories. However, despite having the required permissions (i m the owner), Permission is being denied. I also tried to delete using find and inode number, but again Permission was denied. :wall: I am new to unix so please dumb down... (8 Replies)
Discussion started by: curiosity
8 Replies

5. Shell Programming and Scripting

Delete files in directory using perl

Hello All I am implementing my task in Perl and i found an issue. What i want to do is to remove files from the directory which were made 20 days back using Perl script (9 Replies)
Discussion started by: parthmittal2007
9 Replies

6. Shell Programming and Scripting

Needs to delete particular date files in a directory

Hi Guys, I need help on deleting particular date files in a directory. I have to delete thousands of files with respect to particular date. Could anyone help on this to delete particular date files at a time? Thanks in Advance (2 Replies)
Discussion started by: teddy2882
2 Replies

7. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurence of a specific word

Hello, I have several files in a specific directory. A specific string in one file can occur in another files. If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string. Example. file1 ShortName "Blue... (2 Replies)
Discussion started by: premier_de
2 Replies

8. Shell Programming and Scripting

delete all but one files in a directory

what`s the script to do that? assuming my text file is "test.txt" (10 Replies)
Discussion started by: finalight
10 Replies

9. UNIX for Dummies Questions & Answers

How to Delete Multi Directory and Files

I have a subdirectory which has many child directories and files in it. How can i delete them through a list (txt, rtf. xls , or any file extension) which is created by me. I can not manual delete one by one because it almost over 300 directory and over 4000 files. Any one know please help me? (5 Replies)
Discussion started by: cthinh
5 Replies

10. Shell Programming and Scripting

Delete Some Old files from Particular Directory

Hi Team, I am new to scripting. I want to create a script, which needs to keep only 5 days directories and want to remove the old directory from a particular directory. Can Somebody help me with starting this script. All my directories will be created in the name <YYYYMMDD>. Thanks... (2 Replies)
Discussion started by: siva80_cit
2 Replies
Login or Register to Ask a Question