Solved

Delete lot of files in solaris

Posted on 2011-09-13
4
368 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now