免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1309 | 回复: 4
打印 上一主题 下一主题

[系统管理] 非常郁闷加奇怪的删除脚本,求路过 [复制链接]

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-07-27 17:42 |只看该作者 |倒序浏览
本帖最后由 flutter 于 2012-07-27 18:23 编辑

     各位达人,偶做了一个脚本,删除3天之前的文件,内容如下:

    find /oracle/backup -mtime +3 -type f -name "*.dmp" | xargs rm -rf


    现在最奇怪的是,该目录如下:

-rw-r--r-- 1 oracle dba       25295 Jul 25 04:44 test0120120725.log
-rw-r--r-- 1 oracle dba       27793 Jul 26 04:44 test01_20120726.log
-rw-r--r-- 1 oracle dba       27793 Jul 27 04:44 test01_20120727.log
-rw-r--r-- 1 oracle dba       18387 Jul 26 05:21 test02_20120726.log
-rw-r--r-- 1 oracle dba       26252 Jul 27 05:23 test02_20120727.log
-rw-r--r-- 1 oracle dba       11728 Jul 26 05:41 test03_20120726.log
-rw-r--r-- 1 oracle dba       11728 Jul 27 05:41 test03_20120727.log
-rw-r--r-- 1 oracle dba       14279 Jul 24 19:39 test02_20120724.log
-rw-r--r-- 1 oracle dba       14279 Jul 25 05:31 test02_20120725.log
-rw-r--r-- 1 oracle dba  31131136 Jul 24 19:39 test01_20120724.dmp
-rw-r--r-- 1 oracle dba  28960256 Jul 25 05:31 test01_20120725.dmp
-rw-r--r-- 1 oracle dba  32998912 Jul 26 05:21 test01_20120726.dmp
-rw-r--r-- 1 oracle dba  73263360 Jul 27 05:23 test01_20120727.dmp
-rw-r--r-- 1 oracle dba   6806400 Jul 26 05:41 test02_20120726.dmp
-rw-r--r-- 1 oracle dba   6806400 Jul 27 05:41 test02_20120727.dmp
-rw-r--r-- 1 oracle dba 19647488 Jul 25 04:44 test03_20120725.dmp
-rw-r--r-- 1 oracle dba 18033664 Jul 26 04:44 test03_20120726.dmp
-rw-r--r-- 1 oracle dba 19262464 Jul 27 04:44 test03_20120727.dmp

   可以看到有24,25,26,27的文件,今天是27,我想删除25之前的,可怎么运行都没有删除

find /oracle/backup -mtime +2 -type f -name "*.dmp"  | xargs rm -rf

改成2,也不行!  改成1,奇怪了,倒可以删除26之前的24,25号文件。。

真是郁闷。。。。咋会师啊? ? ?

论坛徽章:
5
未羊
日期:2014-08-04 16:15:21天秤座
日期:2014-08-13 13:52:372015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:112015亚冠之浦和红钻
日期:2015-06-29 15:30:48
2 [报告]
发表于 2012-07-27 17:53 |只看该作者
  1. find /oracle/backup -atime +3 -type f -name "*.dmp" -exec rm -rf {} \;
复制代码
试试看

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
3 [报告]
发表于 2012-07-27 18:30 |只看该作者
:wink:  谢谢啊,在其他机器上试验了哈,我的脚本是可以正确删除地,保留27,26,25三天的

你的脚本也成功删除,不过保留了27,26,25,24四天的,看来mtime,ctime,atime各有不同啊

论坛徽章:
0
4 [报告]
发表于 2012-07-27 19:32 |只看该作者
zz

文件的 Access time,atime 是在读取文件或者执行文件时更改的;
  文件的 Modified time,mtime 是在写入文件时随文件内容的更改而更改的;
  文件的 Create time,ctime 是在写入文件、更改所有者、权限或链接设置时随 Inode 的内容更改而更改的

论坛徽章:
1
巳蛇
日期:2013-10-28 15:55:33
5 [报告]
发表于 2012-07-28 06:15 来自手机 |只看该作者
ctime是 change time ,当文件meta属性改变时更新。
更新mtime时好像也会更新ctime,这个记得不清楚。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP