Linux精講——atime、mtime、ctime
概念
通過 stat filename
命令檢視一個檔案的三個時間屬性
[root@centos01 ~]# stat 1.txt
File: `1.txt'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 803h/2051d Inode: 931337 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-02-27 22:20:10.803907698 +0800
Modify: 2016-02-27 22:20:10.803907698 +0800
Change: 2016-02-27 22:20:10.803907698 +0800
Access
後面的時間即為atime,檔案被讀會更改此屬性
Modify
後面的時間即為mtime,檔案內容改變會更改此屬性
Change
後面的時間即為ctime,inode資訊改變會更改此屬性
如何更改atime、mtime、ctime
如上,1.txt
是新建的一個檔案,初始狀態其三個時間都一樣的
- 當
cat 1.txt
後,atime 改變,mtime 和 ctime 不變
[root@centos01 ~]# cat 1.txt
[root@centos01 ~]# stat 1.txt
File: `1.txt'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 803h/2051d Inode: 931337 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-02-27 22:24:24.653927639 +0800
Modify: 2016-02-27 22:20:10.803907698 +0800
Change: 2016-02-27 22:20:10.803907698 +0800
- 當
echo "123" >> 1.txt
後,mtime 改變,ctime 改變,atime 不變
[root@centos01 ~]# echo "123" >> 1.txt
[root@centos01 ~]# stat 1.txt
File: `1.txt'
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 931337 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-02-27 22:24:24.653927639 +0800
Modify: 2016-02-27 22:29:36.153926096 +0800
Change: 2016-02-27 22:29:36.153926096 +0800
- 當
mv 1.txt 2.txt
/chmod 666 1.txt
等會變更inode資訊的操作會使ctime改變,atime 和 mtime不變
[root@centos01 ~]# chmod 666 1.txt
[root@centos01 ~]# stat 1.txt
File: `1.txt'
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 931337 Links: 1
Access: (0666/-rw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-02-27 22:24:24.653927639 +0800
Modify: 2016-02-27 22:29:36.153926096 +0800
Change: 2016-02-27 22:30:44.079913921 +0800
- mtime 改變一定會導致 ctime 改變
相關文章
- Linux命令:atime,mtime,ctimeLinux
- [20201105]mtime, ctime and atime in Linux.txtLinux
- Linux中atime,ctime與mtime的細節疑問總結Linux
- linux,mtime引數的理解Linux
- C++(asctime()、ctime())C++
- Synchronized 精講synchronized
- CUDA精講(1)
- Mysql 索引精講MySql索引
- 精講Redis:持久化Redis持久化
- Vue —— 精講 VueRouter(1)Vue
- Vue —— VueX精講(1)Vue
- React高階元件精講React元件
- Java設計模式精講Java設計模式
- 精講Redis記憶體模型Redis記憶體模型
- 【原創】HashMap複習精講HashMap
- Flutter動畫之粒子精講Flutter動畫
- 精講Python中的requests方法Python
- 講講我與Linux的初識Linux
- 分散式之 Redis 複習精講分散式Redis
- 方法精講-言語1筆記筆記
- Mvvm 前端資料流框架精講MVVM前端框架
- Django模型中的save方法 精講Django模型
- 微信小程式開發精講微信小程式
- c# System.Text.Json 精講C#JSON
- 來講講Cortex-M、 ARM、和LinuxLinux
- 《Java核心技術面試精講》27講學習總結Java面試
- Linux-workqueue講解Linux
- 學習linux到底有沒捷徑?講講我重入Linux江湖Linux
- 2021李林精講精練880題 【數學二 解析分冊】
- 精講Redis服務架構分析與搭建Redis架構
- PHP 函式庫精講之類與物件PHP函式物件
- 精講Flutter官網的第一個例子Flutter
- 2024年10月精選技術演講
- Go runtime 排程器精講(七):案例分析Go
- 【JAVA】筆記(8)--- java.lang.String 精講Java筆記
- 併發條件佇列之Condition 精講佇列
- 5年運維工程師講講怎麼學Linux運維工程師Linux
- 分散式之訊息佇列複習精講分散式佇列
- [一生一芯筆記]Chisel diplomacy精講筆記Mac