ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

linux 中atime、mtime、ctime

2022-03-27 12:32:25  阅读:186  来源: 互联网

标签:03 27 ctime atime 12 2022 mtime txt root


1、使用stat命令获取atime、mtime、ctime

root@ubuntu01:/home/test# ls
a.txt
root@ubuntu01:/home/test# stat a.txt
  File: a.txt
  Size: 10              Blocks: 8          IO Block: 4096   regular file
Device: 805h/2053d      Inode: 532492      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-03-27 12:00:07.113429738 +0800        ## 最后访问的时间
Modify: 2022-03-27 11:59:40.697435221 +0800        ## 最后修改的时间
Change: 2022-03-27 11:59:40.697435221 +0800        ## 最后改变的时间(属性、权限)
 Birth: -

 

2、atime因为系统性能的问题,已经不再每次访问实时更新了。https://www.cnblogs.com/liujiaxin2018/p/16062424.html

 

3、查看mtime、ctime

root@ubuntu01:/home/test# ls
a.txt
root@ubuntu01:/home/test# stat a.txt    ## 查看三种time
  File: a.txt
  Size: 10              Blocks: 8          IO Block: 4096   regular file
Device: 805h/2053d      Inode: 532492      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-03-27 12:00:07.113429738 +0800
Modify: 2022-03-27 11:59:40.697435221 +0800
Change: 2022-03-27 11:59:40.697435221 +0800
 Birth: -
root@ubuntu01:/home/test# date   ## 查看当前系统时间
2022年 03月 27日 星期日 12:10:09 CST
root@ubuntu01:/home/test# echo "xxxx" >> a.txt   ## 修改文件内容
root@ubuntu01:/home/test# stat a.txt   ## 查看修改和改变时间, 这说明对文件内容的修改直接影响 mtime和ctime
  File: a.txt
  Size: 15              Blocks: 8          IO Block: 4096   regular file
Device: 805h/2053d      Inode: 532492      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-03-27 12:00:07.113429738 +0800
Modify: 2022-03-27 12:10:14.193446498 +0800
Change: 2022-03-27 12:10:14.193446498 +0800
 Birth: -

为什么修改文件内容ctime会发生改变?

当修改文件时,文件大小等也属于文件的属性,因此ctime也会改变。 

 

4、测试ctime

root@ubuntu01:/home/test# ls
a.txt
root@ubuntu01:/home/test# stat a.txt    ## 查看time
  File: a.txt
  Size: 15              Blocks: 8          IO Block: 4096   regular file
Device: 805h/2053d      Inode: 532492      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-03-27 12:00:07.113429738 +0800
Modify: 2022-03-27 12:10:14.193446498 +0800
Change: 2022-03-27 12:10:14.193446498 +0800
 Birth: -
root@ubuntu01:/home/test# ll a.txt   ## 查看权限
-rw-r--r-- 1 root root 15 3月  27 12:10 a.txt
root@ubuntu01:/home/test# date   ## 系统时间
2022年 03月 27日 星期日 12:15:29 CST
root@ubuntu01:/home/test# chmod +x a.txt    ## 修改文件权限
root@ubuntu01:/home/test# ll a.txt         ## 查看权限
-rwxr-xr-x 1 root root 15 3月  27 12:10 a.txt*
root@ubuntu01:/home/test# stat a.txt   ## 统计时间, 说明对权限的修改只影响 ctime。
  File: a.txt
  Size: 15              Blocks: 8          IO Block: 4096   regular file
Device: 805h/2053d      Inode: 532492      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-03-27 12:00:07.113429738 +0800
Modify: 2022-03-27 12:10:14.193446498 +0800
Change: 2022-03-27 12:15:43.007038471 +0800
 Birth: -

 

标签:03,27,ctime,atime,12,2022,mtime,txt,root
来源: https://www.cnblogs.com/liujiaxin2018/p/16062447.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有