Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 0
find -mtime gives unexpected results

$ 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
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,
Old 08-12-2010, 04:57 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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:
-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, 05:19 PM   #4
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...



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 03:57 PM
using find to compare file mtime with another file's mtime TheFueley Linux - Newbie 1 12-23-2008 09:06 PM
'find' gives different results when using -mtime with -print vs -exec BrianK Linux - General 1 12-08-2008 11:32 AM
find command displays unexpected results helptonewbie Linux - Newbie 5 08-12-2008 03:25 AM
mtime in find vs ls lslade Linux - Software 0 11-17-2005 02:06 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:59 PM.

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