Read more
- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- System Administration
- >
- find command for specific date and delete
-
-
Categories
- Topics
- Hybrid IT with Cloud
- Mobile & IoT
- IT for Data & Analytics
- Transformation
- Strategy and Technology
- Products
- Cloud
- Integrated Systems
- Networking
- Servers and Operating Systems
- Services
- Storage
- Company
- Events
- Partner Solutions and Certifications
- Welcome
- Welcome
- Announcements
- Tips and Tricks
- Feedback
-
Blogs
- Alliances
- Around the Storage Block
- Behind the scenes @ Labs
- Converged Data Center Infrastructure
- Digital Transformation
- Grounded in the Cloud
- HPE Careers
- HPE Storage Tech Insiders
- Infrastructure Insights
- Inspiring Progress
- Internet of Things (IoT)
- My Learning Certification
- Networking
- OEM Solutions
- Servers: The Right Compute
- Telecom IQ
- Transforming IT
-
Quick Links
- Community
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Contact
- Email us
- Tell us what you think
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Enterprise.nxt
- Marketplace
- Aruba Airheads Community
-
Categories
-
Forums
-
Blogs
-
InformationEnglish
find command for specific date and delete
SOLVED- 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2010 04:21 AM
04-20-2010 04:21 AM
There is a simple query that I want to find and delete the files older then 30 days from specific folder.Example I want to delete the files before 20 Mar anything in that folder. For that I used the commands.
find /directory -type f -mtime +30 -exec rm {}\;
find /data_yopkg01/gieprd -type f -name "*.*" -mtime +30 -exec rm -f {} +
It deletes the file. But when I check in the folder there any still the files older then 30days.When I check with the command
find /directory -type f -mtime +30 | wc -l
That too shows the difference.
I want to clear the folder what ever before 30 days of file. Can you help me in this please...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2010 04:34 AM
04-20-2010 04:34 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
it can be the directories remaining after deleting. please note that rm does not delete directories.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2010 04:40 AM
04-20-2010 04:40 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
Acutally it deletes the file but only for 30 days i.e. from today if we count it only deletes the file 19th Mar 2010. But when I do ls -lrt there are files that are of 2009 and 2008 that still exists.
I want to remove the files in this /directory which are more then 30 days older.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2010 04:42 AM
04-20-2010 04:42 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
An easy solution, is to create a reference point (file) and then delete files older than that:
# touch -amt 03210000 /var/tmp/myref
# find /path -type f ! -newer /var/tmp/myref -exec rm {} +
The "problem" with using '-mtime' or its companions, is that it works in 24-hour increments.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2010 06:32 AM
04-20-2010 06:32 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
yficcp01$ touch -amt 03300000 /var/tmp/myref
yficcp01$ find /software/oracle/admin/prd206/udump -type f ! -newer /var/tmp/myref | wc -l
22
y
yficcp01$ pwd
/software/oracle/admin/prd206/udump
yficcp01$ ls -ltr |grep Mar|wc -l
42
yficcp01$ ls -ltr |grep Mar
-rw-rw---- 1 oracle dba 111258 Mar 21 01:48 prd206_ora_14347.trc
-rw-rw---- 1 oracle dba 121264 Mar 23 15:56 prd206_ora_4895.trc
-rw-rw---- 1 oracle dba 89518 Mar 23 21:33 prd206_ora_7511.trc
-rw-rw---- 1 oracle dba 109770 Mar 24 19:48 prd206_ora_11461.trc
-rw-rw---- 1 oracle dba 113164 Mar 26 14:52 prd206_ora_15122.trc
-rw-rw---- 1 oracle dba 99354 Mar 26 17:26 prd206_ora_29659.trc
-rw-rw---- 1 oracle dba 87554 Mar 27 06:29 prd206_ora_10175.trc
-rw-rw---- 1 oracle dba 115700 Mar 27 22:10 prd206_ora_5275.trc
-rw-rw---- 1 oracle dba 72254 Mar 28 10:44 prd206_ora_7137.trc
-rw-rw---- 1 oracle dba 84708 Mar 28 20:22 prd206_ora_28043.trc
-rw-rw---- 1 oracle dba 109614 Mar 28 20:35 prd206_ora_29471.trc
-rw-rw---- 1 oracle dba 36388 Mar 29 03:54 prd206_ora_10735.trc
-rw-rw---- 1 oracle dba 77608 Mar 29 04:35 prd206_ora_15657.trc
-rw-rw---- 1 oracle dba 34300 Mar 29 05:25 prd206_ora_20122.trc
-rw-rw---- 1 oracle dba 126112 Mar 29 06:29 prd206_ora_25559.trc
-rw-rw---- 1 oracle dba 82124 Mar 29 06:29 prd206_ora_25557.trc
-rw-rw---- 1 oracle dba 80558 Mar 29 16:21 prd206_ora_20281.trc
-rw-rw---- 1 oracle dba 81666 Mar 29 18:21 prd206_ora_2440.trc
-rw-rw---- 1 oracle dba 36894 Mar 29 18:43 prd206_ora_4674.trc
-rw-rw---- 1 oracle dba 109614 Mar 29 20:22 prd206_ora_13912.trc
-rw-rw---- 1 oracle dba 77034 Mar 29 20:40 prd206_ora_15972.trc
-rw-rw---- 1 oracle dba 122200 Mar 29 23:30 prd206_ora_2685.trc
-rw-rw---- 1 oracle dba 119246 Mar 30 06:50 prd206_ora_15332.trc
-rw-rw---- 1 oracle dba 131776 Mar 30 08:40 prd206_ora_25727.trc
-rw-rw---- 1 oracle dba 76564 Mar 30 08:41 prd206_ora_25803.trc
-rw-rw---- 1 oracle dba 122144 Mar 30 09:25 prd206_ora_29703.trc
-rw-rw---- 1 oracle dba 88182 Mar 30 11:18 prd206_ora_11977.trc
-rw-rw---- 1 oracle dba 79566 Mar 30 11:30 prd206_ora_13143.trc
-rw-rw---- 1 oracle dba 116636 Mar 30 17:05 prd206_ora_15479.trc
-rw-rw---- 1 oracle dba 115304 Mar 30 17:29 prd206_ora_17213.trc
-rw-rw---- 1 oracle dba 112198 Mar 30 18:26 prd206_ora_22730.trc
-rw-rw---- 1 oracle dba 66070 Mar 30 22:59 prd206_ora_17766.trc
-rw-rw---- 1 oracle dba 94264 Mar 30 23:00 prd206_ora_18287.trc
-rw-rw---- 1 oracle dba 103558 Mar 30 23:06 prd206_ora_18909.trc
-rw-rw---- 1 oracle dba 119298 Mar 31 03:15 prd206_ora_12798.trc
-rw-rw---- 1 oracle dba 76330 Mar 31 04:16 prd206_ora_19494.trc
-rw-rw---- 1 oracle dba 34692 Mar 31 04:26 prd206_ora_20195.trc
-rw-rw---- 1 oracle dba 120656 Mar 31 10:58 prd206_ora_29236.trc
-rw-rw---- 1 oracle dba 35204 Mar 31 11:46 prd206_ora_4379.trc
-rw-rw---- 1 oracle dba 95804 Mar 31 14:21 prd206_ora_19492.trc
-rw-rw---- 1 oracle dba 81080 Mar 31 18:30 prd206_ora_13615.trc
-rw-rw---- 1 oracle dba 110318 Mar 31 22:40 prd206_ora_5562.trc
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-20-2010 05:33 PM
04-20-2010 05:33 PM
Re: find command for specific date and delete
Re: find command for specific date and delete
It sure looks like it is.
>With the provided command it shows 22 files. But when I check with the Mar option it shows 42 that's the difference.
Those 20 files are for Mar 30 and 31, which are after the reference file.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-21-2010 01:15 AM
04-21-2010 01:15 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
Thanks for the reply. But I belive u did not get the point what my actual requirement is. I want to delete the files or director anything in this particualr folder older then the date 30th March 2010 for which I made a reference file 30th March . Now you said the files that was shown is after the reference file. But still in the March list I can see files of 20th March and older till 30th March and also 31st March too. Can u help me with the command for which I can remove all the files above the date.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-21-2010 01:23 AM
04-21-2010 01:23 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
But here too I can delete the files of particular March month only.
I thing we can get some clues in find command only.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-21-2010 01:57 AM
04-21-2010 01:57 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
yficcp01$ touch -amt 03300000 /var/tmp/myref
yficcp01$ find /software/oracle/admin/prd206/udump -type f ! -newer /var/tmp/myref | wc -l
22
y
yficcp01$ pwd
/software/oracle/admin/prd206/udump
yficcp01$ ls -ltr |grep Mar|wc -l
42
You used the find command to count the files (|wc -l) however you did not remove them. Then you complain that the "ls -ltr |grep Mar" command is still showing them. Why wouldn't it show them since you did not remove them?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-21-2010 03:26 AM
04-21-2010 03:26 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
Thanks again for the help and will close the thread after assigning points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-21-2010 04:34 AM
04-21-2010 04:34 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
I'm glad Pete straightened things out for you.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-21-2010 10:57 AM
04-21-2010 10:57 AM
SolutionSure I did. You wanted to verify that the command would work so you didn't delete the files. And when you mistakenly compared the files, you thought it worked incorrectly.
My point was to go ahead and remove the files.
If you want to assign more points, you can reopen the thread:
http://forums.itrc.hp.com/service/forums/helptips.do?#41
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-22-2010 07:27 AM
04-22-2010 07:27 AM
Re: find command for specific date and delete
Re: find command for specific date and delete
Thanks again for the help.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2018 Hewlett Packard Enterprise Development LP