Chinaunix

标题: 笨鸟写了一个日志备份的脚本,出错了,请大侠们帮忙! [打印本页]

作者: wenchy001    时间: 2011-06-23 11:33
标题: 笨鸟写了一个日志备份的脚本,出错了,请大侠们帮忙!
脚本的内容是这样的:
test2:/kbstorage/telesaleslog#more telesales.log_del.sh
#/bin/ksh
find /kbstorage/telesaleslog -name telesales.log* -mtime +7 -exec rm {}\;

执行的权限
test2:/kbstorage/telesaleslog#ls -l  telesales.log_del.sh
-rwxrwxr-x    1 root     system           87  6月22 17时35 telesales.log_del.sh

任务计划
crontab -l
0 23 * * * /kbstorage/telesaleslog/telesales.log_del.sh

邮件发过来的错误如下
Your "cron" job executed on test2 on Wed Jun 22 23:00:00 BEIST 201
/kbstorage/telesaleslog/telesales.log_del.sh


produced the following output:

find: 0652-018 An expression term lacks a required parameter.


*****************************************************************
        cron: The previous message is the standard output
        and standard error of one of the cron commands.

我的本意是这样的:
机器每天都会生出这种格式的日志文件:telesales.log.年-月-日,而且没有定期删除,每次备份完以后都要手动删除,非常的麻烦,我想保留最新7天的日志,只需要每天备份前一天就行,自动删除7天前一天的日志,这样日志里面总是最新的7天日志。我是个菜鸟,希望各位大侠们帮助小弟解决问题,比较的急,谢谢了!
作者: tianyue01    时间: 2011-06-23 13:51
你的shell单独执行过了吗?
没有{}\之间空格就会出0652-018错
作者: yddll    时间: 2011-06-23 14:16
要会man

注意空格
作者: wenchy001    时间: 2011-06-23 17:44
你的shell单独执行过了吗?
没有{}\之间空格就会出0652-018错
tianyue01 发表于 2011-06-23 13:51


谢谢了,这个我没有单独执行过,我也不清楚加“{}\”是干嘛,但是要把这个去掉的话,会不会把所以的日志都删除啊??
作者: wenchy001    时间: 2011-06-23 18:17
你的shell单独执行过了吗?
没有{}\之间空格就会出0652-018错
tianyue01 发表于 2011-06-23 13:51



    刚才运行了一下脚本,加不加“{}\”都会报0652-018这个错误。╮(╯▽╰)╭
作者: wenchy001    时间: 2011-06-23 18:59
要会man

注意空格
yddll 发表于 2011-06-23 14:16



    find /kbstorage/telesaleslog -name telesales.log* -mtime +7 -exec rm {}\;大括号后面有空格

find /kbstorage/telesaleslog -name telesales.log* -mtime +7 -exec rm {}  \;  执行是没有问题了,但是没有达到我想要的效果,求大侠们帮助。谢谢




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2