關於Linux系統中的Access time,Modify time和Change time

來源:互聯網
上載者:User


關於Linux系統中的Access time,Modify time和Change time  在linux系統中,檔案和目錄的inode資訊中,包含三項和時間有關的內容,分別是:      Access time, Modify  time,和Change time.   www.2cto.com         用檔案來做個例子.比如,建立測試檔案'1',使用命令stat查看其inode內容,顯示類似下面:Shell代碼  $ stat 1    File: `1'    Size: 6               Blocks: 8          IO Block: 4096   regular file  Device: fd00h/64768d    Inode: 117604369   Links: 1  Access: (0644/-rw-r--r--)  Uid: (  503/ ***)   Gid: (  100/   users)  Access: 2012-11-19 11:56:06.000000000 +0800  Modify: 2012-11-19 11:56:20.000000000 +0800  Change: 2012-11-19 11:56:20.000000000 +0800         Access time,指最近一次的程式對檔案(目錄)的直接存取時間.比如下面的例子:Shell代碼  $cat 1  1  2  3    $ stat 1    File: `1'    Size: 6               Blocks: 8          IO Block: 4096   regular file  Device: fd00h/64768d    Inode: 117604369   Links: 1  Access: (0644/-rw-r--r--)  Uid: (  503/ ***)   Gid: (  100/   users)  Access: 2012-11-19 14:14:33.000000000 +0800  Modify: 2012-11-19 11:56:20.000000000 +0800  Change: 2012-11-19 11:56:20.000000000 +0800        這裡Access time發生了變化,而其它兩項未變動.       Modify time,指最近一次的檔案(目錄)的內容被改動的時間.比如下面的例子:Shell代碼  $echo '4' >> 1  $ stat 1    File: `1'    Size: 8               Blocks: 8          IO Block: 4096   regular file  Device: fd00h/64768d    Inode: 117604369   Links: 1  Access: (0644/-rw-r--r--)  Uid: (  503/ ***)   Gid: (  100/   users)  Access: 2012-11-19 14:14:33.000000000 +0800  Modify: 2012-11-19 14:17:51.000000000 +0800  Change: 2012-11-19 14:17:51.000000000 +0800         這裡,Modify time已經發生了變化.       Change time,指最近一次的檔案(目錄)的inode資訊被改變的時間.在上面的'Modify time'的例子中可以看到,Change time同時也發生了變化.這是因為檔案的內容被修改後,相應的資訊也會發生變化,比如檔案大小'Size'.       如果是一些單獨改變檔案(目錄)的inode資訊的操作,則只會對Change time產生影響.比如下面的例子:Shell代碼  $mv 1 2  $stat 2    File: `2'    Size: 8               Blocks: 8          IO Block: 4096   regular file  Device: fd00h/64768d    Inode: 117604369   Links: 1  Access: (0644/-rw-r--r--)  Uid: (  503/ ***)   Gid: (  100/   users)  Access: 2012-11-19 14:14:33.000000000 +0800  Modify: 2012-11-19 14:17:51.000000000 +0800  Change: 2012-11-19 14:23:38.000000000 +0800         上面的操作對檔案'1'進行了改名,所以只是影響了Change time.       如果使用命令'ls',其有三個選項: '-u', '-t', 和'-c',分別對應的就是Access time, Modify time和Change time.使用這些選項,命令'ls'的輸出會根據相應的time來進行排序.預設的,'ls'採用的是Modify time,即選項'-t'.      另外,如果在上面使用'ls'時,配合選項'--full-time',則在輸出中可以顯示詳細的time資訊.
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.