The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
delete all but one files in a directory finalight Shell Programming and Scripting 10 05-21-2008 03:51 AM
How to Delete Multi Directory and Files cthinh UNIX for Dummies Questions & Answers 5 05-08-2008 04:03 AM
Delete Some Old files from Particular Directory siva80_cit Shell Programming and Scripting 2 12-11-2006 06:47 AM
delete files in specific directory legato Shell Programming and Scripting 2 03-29-2006 09:46 PM
CRON. How to delete files within a directory southoxon UNIX for Dummies Questions & Answers 1 08-24-2003 10:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-31-2007
plcyber plcyber is offline
Registered User
  
 

Join Date: May 2007
Posts: 2
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 (permalink)  
Old 05-31-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
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 (permalink)  
Old 06-01-2007
plcyber plcyber is offline
Registered User
  
 

Join Date: May 2007
Posts: 2
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 (permalink)  
Old 06-01-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
It's not supposed to print anything on the screen, it's spending all it's time doing it's job.

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 (permalink)  
Old 06-01-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
Note: You should delete not only the files but also delete and recreate the directory.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0