TOC

Linux 文件属性(stat)

  • atime:access time,访问时间
  • mtime:change time,修改时间,内容修改
  • ctime:modify time,变更时间,内容修改,或者元数据修改
  • crtime:create time / birth time,创建时间,部分文件系统支持(Ext4,btrfs,xfs)
[root@localhost]# stat abc.txt
  File: `abc.txt'
  Size: 11214           Blocks: 24         IO Block: 4096   regular file
Device: fc10h/64528d    Inode: 3153180     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-07-09 19:35:42.321279859 +0800
Modify: 2016-07-09 19:35:42.321279859 +0800
Change: 2016-07-09 19:35:42.321279859 +0800
[root@localhost]# cat abc.txt > /dev/null
[root@localhost]# stat abc.txt
  File: `abc.txt'
  Size: 11214           Blocks: 24         IO Block: 4096   regular file
Device: fc10h/64528d    Inode: 3153180     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-07-09 19:35:42.321279859 +0800
Modify: 2016-07-09 19:35:42.321279859 +0800
Change: 2016-07-09 19:35:42.321279859 +0800
[root@localhost]# mount
/dev/vda1 on / type ext4 (rw,noatime,errors=remount-ro)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/vdb on /data type ext4 (rw,noatime)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

重点是 noatime 选项,表示文件系统忽略 atime 的变更,因为频繁的 atime 变更对性能有影响。

如果你有魔法,你可以看到一个评论框~