- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Calculating Date
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-22-2005 12:05 AM
02-22-2005 12:05 AM
I'm trying to create a script to remove files older than 90 days from a specific directory automatically. I have never done this before. I have no idea from where to start, so I'm calling your help.
I don't know the best way to take the current date and subtract from it 90 days.
I was taking the current date this way:
DATE=`date "+%b %d"`
This way, i was receiving the DATE like this "FEB 22". I was thinking in use it because when we do "ls -al" we got the output like this one:
-rw------- 1 ssbrmb users 1200 Jan 10 08:50 .ICEauthority
-rw------- 1 ssbrmb users 154 Jan 10 08:50 .TTauthority
-rw------- 1 ssbrmb users 98 Jan 10 08:50 .Xauthority
-r--r--r-- 1 ssbrmb users 832 Nov 14 2000 .cshrc
drwxr-xr-x 11 ssbrmb users 8192 Jan 12 09:25 .dt
-rwxr-xr-x 1 ssbrmb users 5451 Dec 15 16:40 .dtprofile
-r--r--r-- 1 ssbrmb users 347 Nov 14 2000 .exrc
-r--r--r-- 1 ssbrmb users 334 Nov 14 2000 .login
-r--r--r-- 1 ssbrmb users 439 Nov 14 2000 .profile
-rw------- 1 ssbrmb users 2440 Feb 21 08:52 .sh_history
So i thought the best way to subtract the date was using the same format...
But I don't get the solution...
Can you help me?
Thanks,
Rafel M. Braga
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 12:11 AM
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 12:14 AM
02-22-2005 12:14 AM
Re: Calculating Date
find /dir -type f -mtime +90 -exec rm {} \;
- or -
find /dir -type f -mtime +90 |xargs rm
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 12:15 AM
02-22-2005 12:15 AM
Re: Calculating Date
you can use the find command:
find /path/to/dir -mtime +30 -exec ll {} \;
(gives a long list of files modified more than 30 days ago)
find /path/to/dir -mtime +30 -exec rm {} \;
(to delete them)
regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 12:16 AM
02-22-2005 12:16 AM