I'm running the following command which is supposed to find specific directories according to their Access-Time metadata detail however for some reason the find command changes the access time of these directories.

find /my/directory/ -mindepth 3 -maxdepth 3 -atime +2 -type d

Every time the above command runs it changes the access-time of the directories to the time in which it was executed.

I couldn't find any option for the "find" command that speaks of preserving metadata. Any ideas here would be greatly appreciated.


  • 1
    An option could be to run find on a read-only snapshot of the filesystem if using LVM/btrfs/zfs (that would also help with getting a consistent output in case something modifies the files in there while find is running). – Stéphane Chazelas Jun 19 '14 at 8:32

access times are a feature of the filesystem. individual programs cannot prevent this. it has to be disabled on the filesystem.

you can disable access time updates for the files:

chattr -R +A  /my/directory

or mount the filesystem using noatime to disable access time updates for the entire filesystem.

note that with both options above access times updates are only disabled for reading. writing to the file will still update access times.

  • Yeah, I know about the FS noatime option however my find is part of a script that performs actions according to the atime of directories it finds hence stopping atime updates in the FS is not an option. – Nir Ben-Or Jun 19 '14 at 8:13
  • Actually, this does give me the solution - I'm now executing the command you suggested just before my find command in the script, then when the find command finishes i execute chattr again with the -A flag. Thank you very much for the idea! – Nir Ben-Or Jun 22 '14 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.