Is it touch(1) from coreutils-8.4-37.el6.x86_64 or my brain which is broken?
$ touch abc
$ LANG=C stat abc
File: `abc'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd04h/64772d Inode: 10485773 Links: 1
Access: (0664/-rw-rw-r--) Uid: (3060399/ nodakai) Gid: ( 418/ quant)
Access: 2016-10-14 18:42:06.189751847 +0800
Modify: 2016-10-14 18:42:06.189751847 +0800
Change: 2016-10-14 18:42:06.189751847 +0800
$ touch -a abc
$ LANG=C stat abc
File: `abc'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd04h/64772d Inode: 10485773 Links: 1
Access: (0664/-rw-rw-r--) Uid: (3060399/ nodakai) Gid: ( 418/ quant)
Access: 2016-10-14 18:42:17.374235446 +0800
Modify: 2016-10-14 18:42:06.189751847 +0800
Change: 2016-10-14 18:42:17.374235446 +0800
$ touch --help | grep 'access time'
-a change only the access time
As you see, it was not only atime but also ctime which was updated by touch -a
!?!?
The filesystem is ext4 over LVM if that makes any differences.
Best Answer
touch
is specified as changing file access and modification times; changing the change time is a side-effect of the change to the file's metadata, andtouch
doesn't have any control over that (see also thefutimens()
andutimensat()
functions used bytouch
).-a
and-m
are understood in this context: by defaulttouch
changes both access and modification times (and the system updates the change time); with-a
, it only changes the access time, with-m
, it only changes the modification time.You can see the difference if you specify a time other than the current time: the access and/or modification times will be changed to the value you specify, but the change time will be updated to the current time.