- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- remove files older than a certain date/time
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
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
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
02-24-2003 11:49 AM
02-24-2003 11:49 AM
I am aware of the FIND command, but this only find the files that are older than 'n' days (in integer). I want to specify a time also.
Is there a quick one line code, or will I have to get a bigger set, and use SED etc to parse the columns and determine the time ?
Thanks in advance :-)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2003 11:53 AM
02-24-2003 11:53 AM
Re: remove files older than a certain date/time
You can touch a file and give it a specific date and time stamp.
You could then use this file as a reference file for the '-newer' argument to find. Just remember to do a '! -newer' so it looks for thing NOT NEWER than the referenced file.
Have a look at the man pages 'man find' and 'man touch' for more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2003 11:56 AM
02-24-2003 11:56 AM
Re: remove files older than a certain date/time
touch 200302011137.43 /tmp/testfile
find /yourdir ! -newer /tmp/testfile
This creates a file with a modify time of the value specified on the "touch" command (see man touch).
The "!" means "not", so find will look for files not newer than the data/time stamp on /tmp/testfile.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2003 11:56 AM
02-24-2003 11:56 AM
SolutionUse the touch command to create a file at the moment in time you wish to use as cutoff
touch -t 200301101234 foo
This will create foo & set it's date/time to Jan 10 12:34 PM
Then use find as follows:
find /search_start ! -newer /path/to/foo -exec rm {} \;
This tells it NOT newer than the date/time stamp on foo.
Do the above with ll in place of rm to verify just what WILL be deleted.
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2003 12:00 PM
02-24-2003 12:00 PM
Re: remove files older than a certain date/time
# touch 02241400 /tmp/ref ...Feb 24 at 1400
# cd /dir
# find . -xdev -type f ! -newer /tmp/ref|xargs rm
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2003 11:31 PM
02-24-2003 11:31 PM
Re: remove files older than a certain date/time
I have put such a line in my crontab (root) to remove files older than 4 days in a directory.
55 23 * * * /usr/bin/find /d/
Cheers,
ionut