Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delete lot of files in solaris

Posted on 2011-09-13
4
Medium Priority
?
435 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 1500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

927 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