Solved

Delete lot of files in solaris

Posted on 2011-09-13
4
401 Views
Last Modified: 2012-05-12
Hi,

I have lots of files (nearly 900000)in a directory and I need to remove files older than 30 days in a quick way.

I tried to execute  find . -name "*____.tmp"  -mtime +30 -exec rm -rf {} \;

but it is too long time.

Regards
Chinna
0
Comment
Question by:tnrchinna
  • 2
4 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36534134
find . -name "*____.tmp" -mtime +30 | xargs rm -f
0
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 36534135
How about creating a temp directory and moving the files to the temporary directory, then remove the whole temp directory? Like this:

find . -name "*____.tmp"  -mtime +30 -exec mv {} /tmpdir \;
rm -rf /tmpdir
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 36534457
Do you have to process files in subdirectories?

If you don't you could speed up the whole thing a bit (depending on the actual number of subdirs, of course):

find . \( -type d \! -name '.' -prune \)  -o -type f -name "*____.tmp" -mtime +30 | xargs rm -f

If you have GNU find installed:

find . -maxdepth 1 -type f -name "*____.tmp" -mtime +30 | xargs rm -f

wmp

0
 

Author Closing Comment

by:tnrchinna
ID: 36541008
I tried all the ways, mentioned above only last one better than all. Initiating during downtime and it is still taking long time but no option.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question