Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Search this Thread
Old 02-13-2009, 11:24 AM   #1
LQ Newbie
Registered: Jan 2009
Location: Phoenix, AZ
Posts: 3

Rep: Reputation: 0
alternative command for "find -mtime "

I assumed that I'd find a post similar to this one already... but have had no luck finding any.

So I am trying to run a backup/cleanup job and need to delete files that are older than 30 days. Here is what I use:

find <path> -mtime +30 -exec rm -f {} \

I have a highly split up directory tree structure, with more than 25K folders to delete daily, and the find command in itself seems like it takes forever to run.

Any ideas on how I could make this more efficient?
Old 02-13-2009, 05:17 PM   #2
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
You could try replacing the \ with a + at the end of your find command. Then instead of starting a new rm process for each file, rm is called just once with a list of all the found files.

OTOH if you've got 25K+ files that's probably too many for a single command line, and I've got a feeling that to increase that limit you need to recompile the kernel. But you could give it a go, and if it complains there are too many arguments, you split the find command up by executing it on the subdirs of the path you're using at the mo.
Old 02-13-2009, 05:41 PM   #3
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,557

Rep: Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085
Originally Posted by sspisharody View Post
I have a highly split up directory tree structure, with more than 25K folders to delete daily, and the find command in itself seems like it takes forever to run.
Does this imply you are traversing 30 x 25k (plus) every day ?. If so I'm not surprised it takes a while.
I'd be inclined to look at redesigning things, and maybe have each day under a different directory - that way you could just prune the oldest (after 30 days) directory. No search necessary.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a single "Find" Command to find files bases on multiple criteria roboxooo Linux - Newbie 6 01-15-2009 05:13 AM
Is there an alternative command for "ipmasqadm" on Fedora Core 6? bluntvillan Linux - Networking 1 02-24-2008 01:14 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
What does "2>" do when added to "find" command? O(V)eGA_l2el) Fedora 8 08-06-2007 03:25 AM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 08:42 AM

All times are GMT -5. The time now is 03:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration