Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-23-2006, 09:16 PM
|
#1
|
|
LQ Newbie
Registered: May 2006
Posts: 25
Rep:
|
delete file more than 50 days
i need some help here
1. how can i delete file more than 50 days?
2. what is the difference between -ctime and -mtime?
thanks
|
|
|
|
05-23-2006, 09:28 PM
|
#2
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 14,964
|
|
|
|
|
05-23-2006, 09:34 PM
|
#3
|
|
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,591
|
Code:
/usr/bin/find /somedir/ -daystart -mtime +50 -type f -exec /bin/rm -f {} \;
The above will delete files older than 50 days in directory '/somedir'.
The ctime is the last time the inode for a file (it's entry in the filesystem) was last changed. The mtime is when the file was last modified. You are almost always interested in the mtime.
|
|
|
|
05-24-2006, 12:26 AM
|
#4
|
|
LQ Newbie
Registered: May 2006
Posts: 25
Original Poster
Rep:
|
ok..but can i know why the below codes is needed?
i mean can i just find . -daystart -mtime +50 -type f -exec rm{} \;?
|
|
|
|
05-24-2006, 02:06 AM
|
#5
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 14,964
|
find is usually in /usr/bin, so as long as it's in your PATH var, you'll be fine using the short form.
For the paranoid, you always specify the full path in case someone's managed to hack your PATH var, which is also why root user dosn't have '.' ie current dir in PATH.
Actually (just checked), my normal user doesn't either....
|
|
|
|
05-24-2006, 02:21 AM
|
#6
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
There are 3 types of timestamps in linux. - atime: the time a file was last accessed
- mtime: the time the file was last modified
- ctime: the time the inode was altered. This can happen by either changing permissions for a file or renaming it.
|
|
|
|
05-24-2006, 03:13 AM
|
#7
|
|
LQ Newbie
Registered: May 2006
Posts: 25
Original Poster
Rep:
|
i've created a file yesterday 23 may 2006 14:26 so to try chrism01's code but alter it to this:
find . -daystart -mtime +1 -type f -exec rm -f {} \;
but it doesn't work..the file still exists..how?
about explanation of the timestamps..thanks
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:13 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|