0

I have two different linux based systems where the find command doesn't seem to be working as expected.

I have a directory. In it I run...

ls -l

and the system returns...

drwxr-xr-x 2 panopticon36 panopticon36 4096 May 22 12:28 folder1
drwxr-xr-x 2 panopticon36 panopticon36 4096 May 22 12:28 folder2
drwxr-xr-x 2 panopticon36 panopticon36 4096 May 22 12:25 folder3
drwxr-xr-x 2 panopticon36 panopticon36 4096 May 24 09:52 folder4

today is 5/24/17.

In the same directory, if I run...

find . -mtime +1 -type d

the system returns nothing.

From my understanding, the find command should find all directories "-type d" in the current directory "." that are more than 1 day old "-mtime +1". So...

folder1
folder2
folder3

should all be listed to my understanding. Two systems under my care are exhibiting this behavior. Am I doing something incorrectly or missing something? Could something be modifying directories in such a way that ls -l does not reflect the correct date modified? Is there something else I could attempt to troubleshoot the issue? All help is welcome.

1 Answer 1

1

Due to the weird way the mtime is rounded up, +1 means "48 hours or more". This is documented on the man page.

The way to memorize it is to start from the most basic use: -mtime 1 which means that file was accessed 24 hours ago plus any fraction (for example 24+23 hours would also match). From this follows "logically" what +1 and -1 mean.

4
  • Yeah but folders 1 through 3 were all modified (May 22 according to ls -l) 2 days ago, so +1 should list them. I see what you are saying and that would make sense if the folders were last modified May 23rd. May 24, 2017 at 16:42
  • Only if you have run find on May 24, 12:28 or later. Have you? And it could be a timezone-related issue like this question.
    – kubanczyk
    May 24, 2017 at 16:45
  • I'm sorry. You are correct. +1 indicates files a full 48 hours later than the time at which the command is run. Thank you for the clarification. I appreciate it. May 24, 2017 at 17:18
  • @DeanTaylor You may want to look at -daystart if you'd rather count calendar days than seconds Jun 29, 2017 at 20:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .