- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Keep last 30 days of files in a directory
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
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
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
тАО01-11-2010 02:05 AM
тАО01-11-2010 02:05 AM
Keep last 30 days of files in a directory
What's the find command that keeps the last 30 days of data in a specific directory?
Regards
Feng Lin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 02:09 AM
тАО01-11-2010 02:09 AM
Re: Keep last 30 days of files in a directory
# find /path -xdev -type f -mtime +30 -exec echo {} +
If you are satisfied with the results when you run this, change the 'echo' to 'rm'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 02:29 AM
тАО01-11-2010 02:29 AM
Re: Keep last 30 days of files in a directory
Your command works ok on HP-UX. Can you make it work on linux as well?
Regards
Feng Lin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 03:06 AM
тАО01-11-2010 03:06 AM
Re: Keep last 30 days of files in a directory
find /home -xdev -type f -mtime +30 -exec echo {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 03:10 AM
тАО01-11-2010 03:10 AM
Re: Keep last 30 days of files in a directory
# deletes all regular file in /Dir that are older than 3 hours
first try with ls:
$ ls /Dir/**/*(.mh+3)
And if it's ok with you, you cam remove it:
$ rm -f /Dir/**/*(.mh+3)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 05:00 AM
тАО01-11-2010 05:00 AM
Re: Keep last 30 days of files in a directory
it is good for 11i v2 ;
# find /home -xdev -type f -mtime +590 -exec echo {} +
/home/informix/.dtprofile /home/informix/update_statistics.sh /home/informix/.profile.orig . . .
but (correct me if I am mistaken but) actually does not seem to be working in 11i v1;
# find /tmp -xdev -type f -mtime +30 -exec echo {} +
#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 05:01 AM
тАО01-11-2010 05:01 AM
Re: Keep last 30 days of files in a directory
of course it is working with 11i v1;
find /home -xdev -type f -mtime +30 -exec echo {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 06:26 AM
тАО01-11-2010 06:26 AM
Re: Keep last 30 days of files in a directory
Try;
find /
Good Luck
Nafez ALNajjar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 06:46 AM
тАО01-11-2010 06:46 AM
Re: Keep last 30 days of files in a directory
> Hi JRF. Your command works ok on HP-UX. Can you make it work on linux as well?
What's not working for you?
Change '/path' to whatever directory you want to visit.
The use the '+' character to terminate the '-exec' argument is very efficient. Multiple arguments are collected and the '-exec' command run for them. If you chose the '\;' terminator you must escape (backslash) the ';' so that the shell doesn't see it. This form is much less efficient since the '-exec' command argument is spawned for _every_ argument it processes.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2010 08:32 PM
тАО01-11-2010 08:32 PM
Re: Keep last 30 days of files in a directory
The one ending with the \ works for linux.
Thanks to all.
Regards
Feng Lin