linux 中atime、mtime、ctime
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: -
分类:
linux shell
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 上周热点回顾(2.17-2.23)
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
2021-03-27 c语言中输入数组元素的值