- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Wana help in writing a script
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
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
тАО06-06-2007 11:34 PM
тАО06-06-2007 11:34 PM
Wana help in writing a script
I am looking for a command which can filter out all the files which have been created or modified 15 days or before from the today's date.
And I have to run this script/command on daily basis. So I want it to take current system date itself (I mean I want to make it generalize).
Can any buddy help me out in this.
Regards,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 11:49 PM
тАО06-06-2007 11:49 PM
Re: Wana help in writing a script
find /start_dir -type f -mtime +15
That will give you a list of files created or modified prior to the last 15 days.
To exclude those:
find /start_dir -type f ! -mtime +15
The results of either of those can be piped to xargs to take some action on them. To remove the files older than 15 days:
find /start_dir -type f -mtime +15 |xargs rm
Pete
Pete
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 11:50 PM
тАО06-06-2007 11:50 PM
Re: Wana help in writing a script
First, Unix does not have a "creation" timestamp. There is a last-modified ('mtime') value that at the moment of creation represents the named time but thereafter the value is the last modification time.
# find /path -xdev -type f -mtime +15
See the manpages for 'find(1) and 'stat(2)' for more details.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 11:51 PM
тАО06-06-2007 11:51 PM
Re: Wana help in writing a script
maybe a command like this :
find / -type f -mtime +15 -print -exec ls {} \;
(that take file older than 15 days)
could be a good starting point for your script.
Hth
regards
pg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 11:55 PM
тАО06-06-2007 11:55 PM
Re: Wana help in writing a script
I guess I'm interpreting Ashish's request differently...
Show files in /path with last modified time less than 15 days:
$ find /path -type f -mtime -15 -print
If you wish to perform an action on these files, 'find' has the '-exec
Note that there is no notion of a "creation date" for files under UNIX. However, as long as a file's timestamp hasn't changed since it was created, last modification time will function as a pseudo-creation time.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-07-2007 02:17 AM
тАО06-07-2007 02:17 AM
Re: Wana help in writing a script
And yes, It was my mistake to write "creation time" in my question. May be because of too much of work :) I wrote that. But I meant actually with modified time only.
Thanks & Regards,
Ashish