atime、ctime與mtime,atime,ctimemtime

來源:互聯網
上載者:User

atime、ctime與mtime,atime,ctimemtime

1. atime、ctime與mtime

atime是指access time,即檔案被讀取或者執行的時間 (修改檔案是不會改變access time的)。

ctime即change time,檔案狀態改變時間,指檔案的i結點被修改的時間,如通過chmod修改檔案屬性,ctime就會被修改。

mtime即modify time,指檔案內容被修改的時間。

 

使用stat可以查看檔案的atime、ctime、mtime。

stat /etc/passwd
File: `/etc/passwd'
Size: 1381 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768dInode: 399683 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-01-23 23:53:40.096000003 +0800
Modify: 2016-10-22 14:16:07.037115838 +0800
Change: 2016-10-22 14:16:07.038115837 +0800

 

也可以使用ls查看檔案的atime、ctime、mtime。

通常情況下我們使用的ls –l /etc/passwd指示的是檔案的modify time。

ls –lu /etc/passwd 或者ls –l –time=atime /etc/passwd指示的是檔案的access time

ls –lc /etc/passwd 或者ls –l –time=ctime /etc/passwd 指示的是檔案的change time

 

使用touch可以改變這三個時間。關於使用touch改變atime、ctime、mtime的方法,此處不做介紹。

 

 

2. find . –mtime中的參數n

find . –mtime n中的n指的是24*n, +n、-n、n分別表示:

+n:  大於n

-n:  小於n

n:  等於n

 

find . –mtime n:  File was last modified n*24 hours ago.

最後一次修改發生在距離目前時間n*24小時至(n+1)*24 小時

find . –mtime +n:

最後一次修改發生在n+1天以前,距離目前時間為(n+1)*24小時或者更早

find . –mtime –n:

最後一次修改發生在n天以內,距離目前時間為n*24小時以內

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.