aix下crontab无法执行日志压缩命令,不定时执行却可以

土匪八号 2014-07-03 10:50:50
写了个定时任务,先压缩日志,之后再删除原日志。
该语句
定时命令如下:
45 10 * * * tar cvf /weblog10/Applog/test-`date +%y%m%d`.tar /weblog10/test && rm -rf /weblog10/test
单独执行: tar cvf /weblog10/Applog/test-`date +%y%m%d`.tar /weblog10/test && rm -rf /weblog10/test 可以正常执行。
但是设置crontab之后却无法执行。
打开了报错日志报如下错误,请各位帮指点下问题原因

Subject: Output from cron job tar cvf /weblog10/Applog/test-`date +, weblog10@Tzjapp, exit status 2

Cron Environment:
SHELL = /usr/bin/sh
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr/java5/bin
CRONDIR=/var/spool/cron/crontabs
ATDIR=/var/spool/cron/atjobs
LOGNAME=weblog10
HOME=/weblog10

Your "cron" job executed on Tzjapp on Thu Jul 3 10:35:00 GMT+08:00
tar cvf /weblog10/Applog/test-`date +


produced the following output:

tar: Jul: A file or directory in the path name does not exist.
tar: 3: A file or directory in the path name does not exist.
tar: 10:35:00: A file or directory in the path name does not exist.
tar: GMT+08:00: A file or directory in the path name does not exist.
tar: 2014: A file or directory in the path name does not exist.


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


...全文
746 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
土匪八号 2014-07-03
  • 打赏
  • 举报
回复
引用 1 楼 ljc007 的回复:
百分号在crontab里面是特殊字符,需要转义: 45 10 * * * tar cvf /weblog10/Applog/test-`date +\%y\%m\%d`.tar /weblog10/test && rm -rf /weblog10/test
可以了,多谢
ljc007 2014-07-03
  • 打赏
  • 举报
回复
百分号在crontab里面是特殊字符,需要转义: 45 10 * * * tar cvf /weblog10/Applog/test-`date +\%y\%m\%d`.tar /weblog10/test && rm -rf /weblog10/test

1,194

社区成员

发帖
与我相关
我的任务
社区描述
该论坛主要探讨IBM AIX平台的安装、部署、应用开发等话题,并为网友们提供自由交流的平台。
社区管理员
  • IBM AIX社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧