+ -
当前位置:首页 → 问答吧 → 笨鸟写了一个日志备份的脚本,出错了,请大侠们帮忙!

笨鸟写了一个日志备份的脚本,出错了,请大侠们帮忙!

时间:2011-06-23

来源:互联网

脚本的内容是这样的:
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天日志。我是个菜鸟,希望各位大侠们帮助小弟解决问题,比较的急,谢谢了!

作者: wenchy001   发布时间: 2011-06-23

你的shell单独执行过了吗?
没有{}\之间空格就会出0652-018错

作者: tianyue01   发布时间: 2011-06-23