Delete lot of files in solaris

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
tnrchinnaAsked:
Who is Participating?
 
woolmilkporcConnect With a Mentor Commented:
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
 
woolmilkporcCommented:
find . -name "*____.tmp" -mtime +30 | xargs rm -f
0
 
Peter KwanCommented:
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
 
tnrchinnaAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.