免费注册 查看新帖 |

Chinaunix

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

关于一个crontab任务的说明 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-07-11 10:49 |只看该作者 |倒序浏览
各位大侠麻烦看看下面这个JOB中find /home/xkg/IpAtmSwitcher/logfiles/ -name "*.log" -mtime 7 -exec rm -rf {} \;

-name和-mtime是啥意思。为什么后面结束要加{} \这两个符号?

论坛徽章:
0
2 [报告]
发表于 2012-07-11 11:23 |只看该作者
回复 1# anline5104


    man find
  1. -mtime n
  2.               File's data was last modified n*24 hours ago.  See the  comments
  3.               for -atime to understand how rounding affects the interpretation
  4.               of file modification times.

  5.        -name pattern
  6.               Base of  file  name  (the  path  with  the  leading  directories
  7.               removed)  matches  shell  pattern  pattern.   The metacharacters
  8.               (`*', `?', and `[]') match a `.' at the start of the  base  name
  9.               (this is a change in findutils-4.2.2; see section STANDARDS CON‐
  10.               FORMANCE below).  To ignore a directory and the files under  it,
  11.               use  -prune; see an example in the description of -path.  Braces
  12.               are not recognised as being special, despite the fact that  some
  13.               shells  including  Bash  imbue  braces with a special meaning in
  14.               shell patterns.  The filename matching is performed with the use
  15.               of  the  fnmatch(3)  library function.   Don't forget to enclose
  16.               the pattern in quotes in order to protect it from  expansion  by
  17.               the shell.
  18. -exec command ;
  19.               Execute  command;  true  if 0 status is returned.  All following
  20.               arguments to find are taken to be arguments to the command until
  21.               an  argument  consisting of `;' is encountered.  The string `{}'
  22.               is replaced by the current file name being processed  everywhere
  23.               it occurs in the arguments to the command, not just in arguments
  24.               where it is alone, as in some versions of find.  Both  of  these
  25.               constructions might need to be escaped (with a `\') or quoted to
  26.               protect them from expansion by the shell.  See the EXAMPLES sec‐
  27.               tion for examples of the use of the -exec option.  The specified
  28.               command is run once for each matched file.  The command is  exe‐
  29.               cuted  in  the starting directory.   There are unavoidable secu‐
  30.               rity problems surrounding use of the -exec  action;  you  should
  31.               use the -execdir option instead.

复制代码

论坛徽章:
0
3 [报告]
发表于 2012-07-11 16:47 |只看该作者
本帖最后由 earwig 于 2012-07-11 16:48 编辑

这个就是查找7天前的.log文件,然后删除。
{}代表找到的结果。
后面的就是固定格式了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP