0

I would like to know how can I preserve file access time ("atime") when using "chmod". Sometimes I need to use the code below:

chmod -R 777 /directory

It works fine, however all the files inside that directory have the access time ("atime") changed to the current time. Do you have any idea?

NOTE: I am using CentOS 8.

Jonathan
  • 11
  • 1
  • I can (only) think of "stupid" method like using `find`, `stat` and `touch` accordingly to "revert" the access time after `chmod`ing each file. (It's probably more complicated, if feasible at all, if you also want to retain the access time of the (sub)directories.) – Tom Yan May 19 '22 at 03:59
  • What amazes me is that even files that are already with permission 777 have their timestamp updated when chmod is executed on them also with 777. chmod should not touch those files if their permission is the same the one being assigned. – Jonathan May 19 '22 at 14:03
  • Ugh, it's not really supposed to "change" the permission. It's like `echo -n meh > some_file` will still nuke `some_file` and write `meh` to it even if its content is already just `meh`. – Tom Yan May 19 '22 at 17:50
  • Btw, you might also want to consider/try `mount -o remount,noatime` the corresponding mountpoint. – Tom Yan May 19 '22 at 17:56

0 Answers0