文章參考?http://blog.itpub.net/26675752/viewspace-1058878/
?
一、概念說明
atime的意思是access time,即文件的最近的一次訪問時間,+n意思為查找n天以前的文件,-n為查找n天以內的文件
?
mtime比較好理解,為modify time,即文件數據最新的修改時間,指的就是 文件內容的最新修改時間 。
?
ctime的意思是change time, 文件狀態最新改變的時間 。是文件的status change time,何為文件的status呢?
我們都知道文件有一些個基本的屬性,權限,用戶,組,大小,修改時間等,只要是這些信息變化了,那么ctime都會發生變化,
所以上面修改文件內容時為何ctime會變化,因為其mtime已經變化了,mtime也是文件狀態的一個。
?
?
二、例子
?
#文件原始屬性 [root@auc-test2 eccs]# stat eccs.log.20 File: "eccs.log.20" Size: 10485916 Blocks: 20488 IO Block: 4096 普通文件 Device: fd02h/64770d Inode: 1834242 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-12-17 02:43:15.901076752 +0800 Modify: 2014-12-17 02:43:15.914076752 +0800 Change: 2014-12-18 13:59:22.242796455 +0800 #修改訪問時間屬性(atime) [root@auc-test2 eccs]# head -n 1 eccs.log.20 2014-12-17T00:51:53+08:00 [INFO] AstL [root@auc-test2 eccs]# stat eccs.log.20 File: "eccs.log.20" Size: 10485916 Blocks: 20488 IO Block: 4096 普通文件 Device: fd02h/64770d Inode: 1834242 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-12-18 14:01:11.791796442 +0800 Modify: 2014-12-17 02:43:15.914076752 +0800 Change: 2014-12-18 13:59:22.242796455 +0800 #修改文件狀態時間屬性(ctime) [root@auc-test2 eccs]# chmod 777 eccs.log.20 [root@auc-test2 eccs]# stat eccs.log.20 File: "eccs.log.20" Size: 10485916 Blocks: 20488 IO Block: 4096 普通文件 Device: fd02h/64770d Inode: 1834242 Links: 1 Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-12-18 14:01:11.791796442 +0800 Modify: 2014-12-17 02:43:15.914076752 +0800 Change: 2014-12-18 14:01:35.286796424 +0800 #修改文件內容時間屬性(mtime) [root@auc-test2 eccs]# echo "huangbiao" >> eccs.log.20 [root@auc-test2 eccs]# stat eccs.log.20 File: "eccs.log.20" Size: 10485926 Blocks: 20488 IO Block: 4096 普通文件 Device: fd02h/64770d Inode: 1834242 Links: 1 Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-12-18 14:01:11.791796442 +0800 Modify: 2014-12-18 14:02:16.853796414 +0800 Change: 2014-12-18 14:02:16.853796414 +0800
?
?三 、顯示說明
1、ls 命令顯示的是 mtime時間
[root@auc-test2 eccs]# stat eccs.log.20 File: "eccs.log.20" Size: 10485926 Blocks: 20488 IO Block: 4096 普通文件 Device: fd02h/64770d Inode: 1834242 Links: 1 Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-12-18 14:01:11.791796442 +0800 Modify: 2014-12-18 14:02:16.853796414 +0800 Change: 2014-12-18 14:08:10.946796334 +0800 [root@auc-test2 eccs]# ll eccs.log.20 -rwxr-xr-x 1 root root 10485926 12月 18 14:02 eccs.log.20
?
?
2、sshd 連接顯示的是mtime時間
?
?
四、根據制定日期刪除文件的腳本
?附件del_file_before_that_day.rar 使用方法
[root@auc-test2 log]# ./del_file_before_that_day.sh 2014-12-17 where do the files store? /abc/efg/
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
