LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 02-13-2009, 10:24 AM   #1
sspisharody
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, 04:17 PM   #2
openSauce
Member
 
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, 04:41 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,271

Rep: Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028
Quote:
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.
 
  


Reply


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 04:13 AM
Is there an alternative command for "ipmasqadm" on Fedora Core 6? bluntvillan Linux - Networking 1 02-24-2008 12:14 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
What does "2>" do when added to "find" command? O(V)eGA_l2el) Fedora 8 08-06-2007 02:25 AM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM


All times are GMT -5. The time now is 07:14 AM.

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