- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- removing files older than 10 days
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2007 03:34 AM
тАО03-02-2007 03:34 AM
removing files older than 10 days
we have a directory that the client dumps many reports into daily but its variable day by day (hundreds to few). to save space, they want me to keep only files that have been created in the last 7 days and delete
everything else in that directory.
here is the command i have:
find /col1ap01/metafile/metarprt/completed -type f -mtime +7 -exec|xargs rm
is that look ok or is there a better way
u mite know of?
thx in advance
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2007 03:46 AM
тАО03-02-2007 03:46 AM
Re: removing files older than 10 days
Drop the '-exec' since you are passing the stream onto 'xargs'.
# find /col1ap01/metafile/metarprt/completed -type f -mtime +7 | xargs rm
Also, there is no such thing as a "creation" date in Unix. Thc closest you get is the last 'modification" timestamp ('mtime') which will coincidently equal a creation point at the moment of creation.
Regards!
...JRF...
- Tags:
- xargs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2007 05:45 AM
тАО03-02-2007 05:45 AM
Re: removing files older than 10 days
# find /col1ap01/metafile/metarprt/completed -type f -mtime +7 -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2007 06:11 AM
тАО03-02-2007 06:11 AM
Re: removing files older than 10 days
The '-exec' option will spawn a separate process for each rm to remove each file. xargs works with groups of files, so you don't spawn as many processes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2007 06:17 AM
тАО03-02-2007 06:17 AM
Re: removing files older than 10 days
> Patrick noted, "Actually xargs is MORE efficient than the '-exec' option in find."
However, if you are running 11i *and* you use '-exec command \+' instead of '-exec command \;' then the '-exec' collects multiple arguments much in the fashion of 'xargs' leading to a vast improvement in performance!
Regards!
...JRF...