Linux下文件的time详解
转载请注明文章转载自:Dbabc.Net [http://dbabc.net]
本文链接:http://dbabc.net/archives/2011/10/09/linux-time-info.shtml
atime(Access time)、ctime(Change time)、mtime(Modified time),其中的时间是以天(24小时)来计的。
amin、cmin、mmin是以分钟来计的
文件的 Access time,atime 是在读取文件或者执行文件时更改的任何对inode的访问都会使此处改变。
文件的 Modified time,mtime 是在写入文件时随文件内容的更改而更改的。
文件的 Change time,ctime 是在写入文件、更改所有者、权限或链接设置时随 Inode 的内容更改而更改的。mtime改变ctime肯定要改变。
粗略来讲如下:
-amin n
查找系统中最后N分钟访问的文件
-atime n
查找系统中最后n*24小时访问的文件
-cmin n
查找系统中最后N分钟被改变文件状态的文件
-ctime n
查找系统中最后n*24小时被改变文件状态的文件
-mmin n
查找系统中最后N分钟被改变文件数据的文件
-mtime n
查找系统中最后n*24小时被改变文件数据的文件
+N表示 当前时间起 (N*24+24)小时这个时间点之前
-N表示 当前时间向前(N*24)小时 至 当前时间
N 表示 当前时间向前[(N+1)*24]小时到(N*24)小时之间的一天时间
【
[root@10.2.1.6 arch]#ls -al
total 1413092
drwxr-x— 2 oracle oinstall 4096 Oct 7 00:00 .
drwxr-x— 3 oracle oinstall 4096 Sep 23 17:45 ..
-rw-r—– 1 oracle oinstall 181289984 Oct 7 00:00 1_10_762627863.arc
-rw-r—– 1 oracle oinstall 188561920 Sep 23 19:25 1_3_762627863.arc
-rw-r—– 1 oracle oinstall 181297664 Sep 25 10:25 1_4_762627863.arc
-rw-r—– 1 oracle oinstall 181296640 Sep 26 23:20 1_5_762627863.arc
-rw-r—– 1 oracle oinstall 181296640 Sep 28 13:00 1_6_762627863.arc
-rw-r—– 1 oracle oinstall 181581312 Sep 29 22:00 1_7_762627863.arc
-rw-r—– 1 oracle oinstall 168896512 Oct 1 10:11 1_8_762627863.arc
-rw-r–r– 1 oracle oinstall 181296640 Oct 4 15:44 1_9_762627863.arc
[root@10.2.1.6 arch]#date
Sun Oct 9 10:07:51 CST 2011
[root@10.2.1.6 arch]#find ./*.arc -mtime 7 -exec ls -al {} \;
-rw-r—– 1 oracle oinstall 168896512 Oct 1 10:11 ./1_8_762627863.arc
[root@10.2.1.6 arch]#date
Sun Oct 9 10:18:40 CST 2011
[root@10.2.1.6 arch]#find ./*.arc -mtime 7 -exec ls -al {} \;
[root@10.2.1.6 arch]#
】
mtime 用 ls -l 看到
atime 用 ls -lu 看到
ctime 用 ls -lc 看到. (ls -li 只有 inode number)
摘书如下:
-c Uses time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n).
-u Uses time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option).
-i For each file, prints the i-node number in the first column of the report.