简单的ctime,atime和mtime区别说明
Posted sushisuren
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单的ctime,atime和mtime区别说明相关的知识,希望对你有一定的参考价值。
简单写写ctime,atime和mtime的区别。
有些教程写的比较复杂,其实简单的很:
atime 就是access time 访问就会改变,无论是cat还是more,只要访问过,就会变。不影响另外两个。
ctime 是change time ,主要是修改权限、所有者才会变,chmod +x ,就会单独修改此时间。不影响另外两个。
如下,修改权限+x后change time 发生变化,其他两个未变
an@an-Y7000:~$ stat 1File: 1
Size: 509 Blocks: 8 IO Block: 4096 regular file
Device: 810h/2064d Inode: 2003 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ an) Gid: ( 1000/ an)
Access: 2022-01-25 16:02:38.020978784 +0800
Modify: 2022-01-11 14:43:12.387342409 +0800
Change: 2022-01-11 14:43:12.387342409 +0800
Birth: -
an@an-Y7000:~$ chmod +x 1
an@an-Y7000:~$ stat 1
File: 1
Size: 509 Blocks: 8 IO Block: 4096 regular file
Device: 810h/2064d Inode: 2003 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1000/ an) Gid: ( 1000/ an)
Access: 2022-01-25 16:02:38.020978784 +0800
Modify: 2022-01-11 14:43:12.387342409 +0800
Change: 2022-01-25 16:02:46.030978913 +0800
Birth: -
mtime 是modify time,未修改过内容,就是创建时间,之后如修改过内容则此时间会变,如用的vim同时 会把atime,ctime 一起修改。
如下,修改一下文本内容,则3个时间一起改变:
an@an-Y7000:~$ stat t.py
File: t.py
Size: 98 Blocks: 8 IO Block: 4096 regular file
Device: 810h/2064d Inode: 15026 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1000/ an) Gid: ( 1000/ an)
Access: 2022-01-01 14:44:59.063923653 +0800
Modify: 2021-11-01 16:14:43.816264464 +0800
Change: 2021-11-01 16:14:43.826264464 +0800
Birth: -
an@an-Y7000:~$ vim t.py
an@an-Y7000:~$ stat t.py
File: t.py
Size: 104 Blocks: 8 IO Block: 4096 regular file
Device: 810h/2064d Inode: 8148 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1000/ an) Gid: ( 1000/ an)
Access: 2022-01-25 16:13:18.420989114 +0800
Modify: 2022-01-25 16:13:18.420989114 +0800
Change: 2022-01-25 16:13:18.430989114 +0800
Birth: -
如只是追加,则只会修改mtime和ctime ,不会修改access time.
an@an-Y7000:~$ stat test.py
File: test.py
Size: 1022 Blocks: 8 IO Block: 4096 regular file
Device: 810h/2064d Inode: 218 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1000/ an) Gid: ( 1000/ an)
Access: 2022-01-01 10:15:36.678685565 +0800
Modify: 2021-10-02 19:52:35.890585412 +0800
Change: 2021-10-02 19:52:35.900585412 +0800
Birth: -
追加文本后,ctime 和mtime 发生改变,atime 未变化
an@an-Y7000:~$ echo "###TEST">> test.py
an@an-Y7000:~$ stat test.py
File: test.py
Size: 1030 Blocks: 8 IO Block: 4096 regular file
Device: 810h/2064d Inode: 218 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1000/ an) Gid: ( 1000/ an)
Access: 2022-01-01 10:15:36.678685565 +0800
Modify: 2022-01-25 16:32:03.501007262 +0800
Change: 2022-01-25 16:32:03.501007262 +0800
Birth: -
以上是关于简单的ctime,atime和mtime区别说明的主要内容,如果未能解决你的问题,请参考以下文章
Linux下find , atime, ctime,mtime