关于LINUX三种时间戳的详细说明(带实验)
2018-03-11 19:54
330 查看
Linux系统将时间标记分三类:
atime( A ccess time):档案上次被读取的时间。
ctime(status C hange time):档案的属性或内容上次被修改的时间。
mtime( M odified time):档案的内容上次被修改的时间。
下面我将用实验给大家讲解一下:
[root@localhost ~]# touch a.txt ==》创建文件a.txt
[root@localhost ~]# stat a.txt ==》查看时间戳
File: "a.txt"
Size: 0 Blocks: 0 IO Block: 4096 普通空文件
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:04.130157512 +0800
Change: 2018-03-10 13:29:04.130157512 +0800
[root@localhost ~]# echo 1>> a.txt ==》向文件a.txt追加内容
[root@localhost ~]# stat a.txt ==》查看追加内容后的文件时间戳
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通文件
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:19.351159892 +0800 ==》时间戳改变
Change: 2018-03-10 13:29:19.351159892 +0800 ==》时间戳改变
[root@localhost ~]# chmod +x a.txt ==》修改文件a.txt的权限
[root@localhost ~]# stat a.txt ==》查看修改权限后的文件时间戳
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通文件
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:19.351159892 +0800
Change: 2018-03-10 13:29:42.156153774 +0800 ==》时间戳改变
[root@localhost ~]# cat a.txt ==》查看文件a.txt
[root@localhost ~]# stat a.txt ==》查看文件a.txt的时间戳
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通文件
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:30:00.010155999 +0800 ==》时间戳改变
Modify: 2018-03-10 13:29:19.351159892 +0800
Change: 2018-03-10 13:29:42.156153774 +0800
[root@localhost ~]# vim a.txt ==》向文件a.txt添加内容
daskhdjkas
"a.txt" 1L, 11C 已写入
[root@localhost ~]# stat a.txt ==>查看文件a.txt的时间戳
File: "a.txt"
Size: 11 Blocks: 8 IO Block: 4096 普通文件
Device: fd00h/64768dInode: 674908 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:30:34.652158960 +0800 ==》时间戳改变
Modify: 2018-03-10 13:30:34.652158960 +0800==》时间戳改变
Change: 2018-03-10 13:30:34.653158940 +0800==》时间戳改变
atime( A ccess time):档案上次被读取的时间。
ctime(status C hange time):档案的属性或内容上次被修改的时间。
mtime( M odified time):档案的内容上次被修改的时间。
下面我将用实验给大家讲解一下:
[root@localhost ~]# touch a.txt ==》创建文件a.txt
[root@localhost ~]# stat a.txt ==》查看时间戳
File: "a.txt"
Size: 0 Blocks: 0 IO Block: 4096 普通空文件
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:04.130157512 +0800
Change: 2018-03-10 13:29:04.130157512 +0800
[root@localhost ~]# echo 1>> a.txt ==》向文件a.txt追加内容
[root@localhost ~]# stat a.txt ==》查看追加内容后的文件时间戳
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通文件
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:19.351159892 +0800 ==》时间戳改变
Change: 2018-03-10 13:29:19.351159892 +0800 ==》时间戳改变
[root@localhost ~]# chmod +x a.txt ==》修改文件a.txt的权限
[root@localhost ~]# stat a.txt ==》查看修改权限后的文件时间戳
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通文件
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:19.351159892 +0800
Change: 2018-03-10 13:29:42.156153774 +0800 ==》时间戳改变
[root@localhost ~]# cat a.txt ==》查看文件a.txt
[root@localhost ~]# stat a.txt ==》查看文件a.txt的时间戳
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通文件
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:30:00.010155999 +0800 ==》时间戳改变
Modify: 2018-03-10 13:29:19.351159892 +0800
Change: 2018-03-10 13:29:42.156153774 +0800
[root@localhost ~]# vim a.txt ==》向文件a.txt添加内容
daskhdjkas
"a.txt" 1L, 11C 已写入
[root@localhost ~]# stat a.txt ==>查看文件a.txt的时间戳
File: "a.txt"
Size: 11 Blocks: 8 IO Block: 4096 普通文件
Device: fd00h/64768dInode: 674908 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:30:34.652158960 +0800 ==》时间戳改变
Modify: 2018-03-10 13:30:34.652158960 +0800==》时间戳改变
Change: 2018-03-10 13:30:34.653158940 +0800==》时间戳改变
相关文章推荐
- 关于linux的时间管理
- Linux学习中的小实验与时间设置
- 在linux 中,文件的三种时间权限
- Linux下文件的三种时间戳
- 在Linux下,一个文件也有三种时间,分别是:访问时间、修改时间、状态改动时间
- 关于排序算法时间效率的一个小实验
- linux文件的三种时间属性
- 探讨linux进程的三种时间(real time, system cpu time, user cpu time)的实现
- 三种睡眠时间函数的区别:linux 的sleep()、usleep()、nanosleep()函数
- 关于Linux中的几个时间变量atime,ctime,mtime
- Linux下关于时间概念的C语言编程
- Linux下文件的三种时间标记
- 关于linux下时间延迟函数精度问题
- 关于Linux下时间编程的问题
- 软硬链接、文件删除原理、linux中的三种时间、chkconfig优化
- 关于linux系统和tomcat时间不一致的问题
- linux关于时间
- linux关于时间
- 关于Linux中ls -l显示时间不全的问题
- C语言零碎记录之Linux下C语言关于时间的函数