- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Linux script for purging old files
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
тАО07-22-2008 09:55 AM
тАО07-22-2008 09:55 AM
I am looking for help on writing a script to purge files that are older than 14 days. I am currently running RHAS 4.0
Please help.
Thanks,
Jorge
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2008 10:55 AM
тАО07-22-2008 10:55 AM
Re: Linux script for purging old files
find some-path... -mtime +14 -exec rm -rf \;
Make sure you test it first by inserting the echo command before "rm".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2008 11:01 AM
тАО07-22-2008 11:01 AM
Re: Linux script for purging old files
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2008 11:21 AM
тАО07-22-2008 11:21 AM
Re: Linux script for purging old files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-22-2008 12:31 PM
тАО07-22-2008 12:31 PM
Re: Linux script for purging old files
So, the codes should look like this?
cd /tmp/log_files
find . -type -f -mtime 2 -name "*.log*" -exec rm -fvr > /tmp/purged.log {} \;
Thanks much!!
Jorge
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2008 07:30 AM
тАО07-23-2008 07:30 AM
Re: Linux script for purging old files
1. The script execute but does nothing. No errors.
2. I have results if I execute the command from the script manually. However, it showed that the log captured the removed files, but leaves the supposely removed files back in the original directory.
Here's the sample of my script.
#! /bin/sh
#
# Delete files that are older than 7 days
cd /tmp/datalog/tdump
find . -type f -mtime 7 -name "*.dlog*" -exec rm -fvr > \tmp\purge.log {} \;
feedback would greatly appreciate it.
Jorge
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2008 07:46 AM
тАО07-23-2008 07:46 AM
Solution#
# Delete files that are older than 7 days
cd /tmp/datalog/tdump
find . -type f -mtime 7 -name "*.dlog*" -exec rm -fvr {} \; > \tmp\purge.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2008 08:03 AM
тАО07-23-2008 08:03 AM
Re: Linux script for purging old files
find . -type f -mtime 7 -name "*.dlog*" -exec rm -fvr > \tmp\purge.log {} \;
It should be
find . -type f -mtime 7 -name "*.dlog*" -exec rm -fvr {} \; > /tmp/purge.log
I will test it out and let you all know.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2008 08:08 PM
тАО07-25-2008 08:08 PM
Re: Linux script for purging old files
Older requires: -mtime +7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2008 08:46 PM
тАО07-30-2008 08:46 PM
Re: Linux script for purging old files
Any ideas??
J