You are not logged in.

#1 2019-05-24 07:06:39

magicloud
Member
Registered: 2014-06-17
Posts: 48

[SOLVED]find -atime does not work as expected.

$ stat indices/Hackage/packages/amazonka/1.6.1/amazonka-1.6.1.tar.gz
Fri 24 May 2019 02:49:47 PM CST
  File: indices/Hackage/packages/amazonka/1.6.1/amazonka-1.6.1.tar.gz
  Size: 41603     	Blocks: 88         IO Block: 4096   regular file
Device: 2eh/46d	Inode: 7434667     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   shida)   Gid: ( 1000/   shida)
Access: 2019-05-21 23:03:29.640264851 +0800
Modify: 2019-05-21 23:03:29.636931518 +0800
Change: 2019-05-21 23:03:29.636931518 +0800
 Birth: 2019-05-21 23:03:27.036931706 +0800
Fri 24 May 2019 02:49:47 PM CST

$ find indices/Hackage/packages -atime +1 | g amazon
Fri 24 May 2019 02:50:10 PM CST
768:indices/Hackage/packages/amazonka-core/1.6.1/amazonka-core-1.6.1.tar.gz
769:indices/Hackage/packages/amazonka/1.6.1/amazonka-1.6.1.tar.gz
770:indices/Hackage/packages/amazonka-s3/1.6.1/amazonka-s3-1.6.1.tar.gz
Fri 24 May 2019 02:50:10 PM CST

$ find indices/Hackage/packages -atime +2 | g amazon
Fri 24 May 2019 02:50:15 PM CST
Fri 24 May 2019 02:50:15 PM CST

Even there is some kind of rounding, I cannot see why the file was not touched "greater than 2 days ago".

Last edited by magicloud (2019-05-24 09:26:56)

Offline

#2 2019-05-24 08:42:58

StefanT
Member
Registered: 2018-02-14
Posts: 2

Re: [SOLVED]find -atime does not work as expected.

-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.

So -atime +2 lists files that have not been accessed in the last 2 days. What you probably want is -atime -2
I fell several times over this in the past as it is IMO inverted to what one would expect by default.

Offline

#3 2019-05-24 09:26:40

magicloud
Member
Registered: 2014-06-17
Posts: 48

Re: [SOLVED]find -atime does not work as expected.

StefanT wrote:

-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.

So -atime +2 lists files that have not been accessed in the last 2 days. What you probably want is -atime -2
I fell several times over this in the past as it is IMO inverted to what one would expect by default.

I see. Thanks.

Offline

Board footer

Powered by FluxBB