How does ctime change?
Solution 1:
There are three time stamps on Unix systems:
-
atime
: Access timeThis time stamp tells you when the file was accessed the last time, including only reading access.
-
ctime
: Change timeThis time stamp tells you when the file attributes (inode information) changed the last time. That includes e.g ownership and permissions, but a content change also triggers an update of this time stamp.
Note that changes to the atime seem to be an exception as they do not trigger a ctime update. This is probably because a simple read access which is enough to trigger an atime update does not make any relevant changes to the file attributes. And one of the main purposes of ctime is to help backup tools to determine if a file has changed. The atime is an irrelevant information for such tools and updating a backup just to update a changed atime because somebody has read the file would be useless.
I'm not sure, but some people think this behavior (changes to atime do not update ctime) is only due to the mount options (likerelatime
) of the underlying file system that caches and delays atime updates in the inode for performance reasons in memory and only applies them to the real inodes on the disk (triggering a ctime update) under certain conditions.
@kos tried it and apparently even when mounting a FS with the `strictatime``option, the ctime seems to never update if the atime changes. -
mtime
: Modification timeThis time stamp tells you when the file's content was modified the last time.
So a simple read access using cat FILENAME
only changes the atime, but not the ctime as no file attribute got modified. The changed atime does not count.