- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- delete based in timestamp
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
10-24-2006 10:24 AM
10-24-2006 10:24 AM
delete based in timestamp
How can I delete files based in its timestamp.
Example:
Delete all files older than October 23, 16:35 Hrs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 11:05 AM
10-24-2006 11:05 AM
Re: delete based in timestamp
touch -t YYYYMMDDhhmm.ss /tmp/referencefile
find /path -type f ! -newer /tmp/referencefile -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2006 11:41 PM
10-24-2006 11:41 PM
Re: delete based in timestamp
please be aware that find will also search through sub-directories !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2006 02:13 AM
10-26-2006 02:13 AM
Re: delete based in timestamp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2006 03:06 AM
10-26-2006 03:06 AM
Re: delete based in timestamp
Is any difference between creation and modification timestamp?
How can I see this two dates of same file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2006 01:16 AM
10-27-2006 01:16 AM
Re: delete based in timestamp
You asked, "Is any difference between creation and modification timestamp?"
There is *NO* creation timestamp for a file in Unix.
You have three timestamps associated with a file. The 'mtime' is the last modification time. When a file is first created, its 'mtime' would represent a creation time, but any subsequent write to the file updates the 'mtime'.
The second timestamp is the last-access time ('atime') which is as the name suggests, the last time a file was read, written or executed.
The last timestamp is the 'ctime' or change-time. Altering a file's permissions, ownership or changing its name updates this timestamp.
All three timestamps are in Epoch seconds --- the number of seconds elapsed since January 1, 1970.
Ivan has already shown hou you can delete files older than a specific date. I would suggest, however, that you optimize:
# find /path -type f ! -newer /tmp/referencefile -exec rm {} \;
...to:
# find /path -xdev -type f ! -newer /tmp/referencefile -exec rm {} +
...if your Unix version supports it, or:
# find /path -xdev -type f ! -newer /tmp/referencefile | xargs rm
The last two cases assemble many filenames into a list that is then passed to the 'rm' process. The first case means that a new 'rm' process will be spawned for *every* file found. Needless to say, creating many processes is far more resource intensive then creating merely a few. With large numbers of files to remove you could easily measure the time in minutes versus seconds!
Regards!
...JRF...