0

As far as I know when atime is set (which is the default) if I touch a file its datetime will be updated:

0 -rw-r--r-- 1 root root 0 Mar 5 11:57 my_file

When I touch the file the date will be updated. I have set noatime and rebooted the server and now when I touch the file date will be updated again. Shouldn't it be the same as before? I supposed that touching a file will not change the access time of the file.

Is this true?

I have checked the partition with mount -l and noatime is present:

/dev/mapper/database-var on /var type xfs (rw,noatime,attr2,inode64,logbsize=256k,sunit=512,swidth=1024,noquota)
3

noatime disables the implicit access time updates (those that occur as a side-effect of an operation on a file); it doesn’t affect explicit access time updates (where a program explicitly asks the operating system to update a file’s access time). When you touch a file, you’re explicitly asking to update the access and modification times, and that’s what happens.

You can touch a file without changing the access time, by using the -m option; only the modification time will be updated.

  • I used touch -m my_file and again time is updated. I checked with ls -l my_file – ALH Mar 5 '18 at 12:11
  • 1
    Well yes, because ls -l shows the modification time; use ls -l --time=access to see the access time. – Stephen Kitt Mar 5 '18 at 12:11
  • Great! Thank you for the time +1. I actually didn't know about explicit and implicit access time. – ALH Mar 5 '18 at 12:12
  • 1
    @ALH It's not the access time that is implicit or explicit, it's the updating of the access time. When using touch, you explicitly update the timestamp. When accessing a file with e.g. an editor, you implicitly update the timestamp (if atime is the active mount option). – Kusalananda Mar 5 '18 at 12:17

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.