LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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

Reply
 
Search this Thread
Old 08-12-2010, 03:53 PM   #1
amchargue
LQ Newbie
 
Registered: Oct 2006
Posts: 9

Rep: Reputation: 0
find -mtime gives unexpected results


Code:
$ ls -l
-rw-r--r--  1 username vuser 35553 Aug  9 18:15 note.20100809_1815.sql
-rw-r--r--  1 username vuser 35553 Aug 10 00:15 note.20100810_0015.sql
-rw-r--r--  1 username vuser 35670 Aug 10 04:15 note.20100810_0415.sql
-rw-r--r--  1 username vuser 35670 Aug 10 06:15 note.20100810_0615.sql
-rw-r--r--  1 username vuser 35661 Aug 10 12:15 note.20100810_1215.sql

$ date
Thu Aug 12 14:49:54 MDT 2010

$ find -mtime +2
$ find -mtime +1
./note.20100810_0415.sql
./note.20100810_0615.sql
./note.20100810_0015.sql
./note.20100810_1215.sql
./note.20100809_1815.sql
Why doesn't find -mtime +2 give any result? Doesn't that mean 2 or more days ago (or more than 2 days ago)? If today is Aug. 12 then the Aug. 9 file should match, no?

Curiously yours,
a
 
Old 08-12-2010, 03:57 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
What's the filesystem? What does -ctime +2 find?
 
Old 08-12-2010, 04:06 PM   #3
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
At 6:15 pm your time, the +2 should match.

It has to do with `find` rounding and disposing of time periods not equal to or greater than a full 24 hour period (i.e fractional 24 hour periods are discarded).

From the man page:
Quote:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional
part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.
The same as above applies to -mtime. So, to match +2, the file must have been modified 3 whole days ago; at this time, it's been accessed about 2.75 days ago.
 
Old 08-12-2010, 04:19 PM   #4
amchargue
LQ Newbie
 
Registered: Oct 2006
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks for your response, I thought it might be something like that but overlooked it in the man page.

The server where I'm having this issue is RHEL 5.

-ctime +2 doesn't give me anything either.

There's also amin/cmin/mmin which could help in some situations...
 
  


Reply

Tags
find


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Command to find only mtime ddenton Linux - General 3 08-12-2010 02:57 PM
using find to compare file mtime with another file's mtime TheFueley Linux - Newbie 1 12-23-2008 08:06 PM
'find' gives different results when using -mtime with -print vs -exec BrianK Linux - General 1 12-08-2008 10:32 AM
find command displays unexpected results helptonewbie Linux - Newbie 5 08-12-2008 02:25 AM
mtime in find vs ls lslade Linux - Software 0 11-17-2005 01:06 PM


All times are GMT -5. The time now is 08:36 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration