在项目过程中要删除一些过期文件,但是到期了,有些文件居然没有被删除。后来发现,原来在转移文件的时候使用的mv命令会影响文件的Change Time,造成文件没有被认定为超时。为了避免类似问题发生,做了个简单的实验,结果如下:值得注意的是从结果看中可以看出当文件被下载时,Access Time也会改变。
touch Access Modify Change
echo   -         Modify Change
vim   Access  Modify Change
cat    Access  -          -
mv    -          -         Change
stat   -          -          -
nginx Access  -          -

过程如下:

[root@localhost teststat]# touch aaa.tmp
[root@localhost teststat]# stat aaa.tmp
  File: `aaa.tmp'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: fd00h/64768d	Inode: 22380566    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-02-01 09:18:57.000000000 +0800
Modify: 2016-02-01 09:18:57.000000000 +0800
Change: 2016-02-01 09:18:57.000000000 +0800
[root@localhost teststat]# echo "help">aaa.tmp 
[root@localhost teststat]# stat aaa.tmp 
  File: `aaa.tmp'
  Size: 5         	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 22380566    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-02-01 09:18:57.000000000 +0800
Modify: 2016-02-01 09:19:21.000000000 +0800
Change: 2016-02-01 09:19:21.000000000 +0800
[root@localhost teststat]# vim aaa.tmp 
[root@localhost teststat]# stat aaa.tmp 
  File: `aaa.tmp'
  Size: 13        	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 22380568    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-02-01 09:20:51.000000000 +0800
Modify: 2016-02-01 09:20:51.000000000 +0800
Change: 2016-02-01 09:20:51.000000000 +0800
[root@localhost teststat]# echo "echo re">>aaa.tmp 
[root@localhost teststat]# stat aaa.tmp 
  File: `aaa.tmp'
  Size: 21        	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 22380568    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-02-01 09:20:51.000000000 +0800
Modify: 2016-02-01 09:21:20.000000000 +0800
Change: 2016-02-01 09:21:20.000000000 +0800
[root@localhost teststat]# cat aaa.tmp 
hello world!
echo re
[root@localhost teststat]# stat aaa.tmp 
  File: `aaa.tmp'
  Size: 21        	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 22380568    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-02-01 09:22:05.000000000 +0800
Modify: 2016-02-01 09:21:20.000000000 +0800
Change: 2016-02-01 09:21:20.000000000 +0800
[root@localhost teststat]# mv aaa.tmp bbb.tmp
[root@localhost teststat]# stat bbb.tmp 
  File: `bbb.tmp'
  Size: 21        	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 22380568    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-02-01 09:22:05.000000000 +0800
Modify: 2016-02-01 09:21:20.000000000 +0800
Change: 2016-02-01 09:22:28.000000000 +0800
然后用nginx下载文件,再次查看文件状态
[root@localhost teststat]# stat bbb.tmp 
  File: `bbb.tmp'
  Size: 21        	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 22380568    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-02-01 09:42:05.000000000 +0800
Modify: 2016-02-01 09:21:20.000000000 +0800
Change: 2016-02-01 09:22:28.000000000 +0800

  

posted on 2016-02-01 12:44  步孤天  阅读(276)  评论(0编辑  收藏  举报