我最近经历了一个日志监视问题这是通过运行修复的export DATE_MANIP=DM5
。当我注销时,cron 似乎忘记了这一点(大概是因为它没有保存)。
在哪里可以添加这个自定义环境变量?由于我不管理 logwatch 的代码,因此我不想export
在启动的脚本中添加命令。我尝试添加export DATE_MANIP=DM5
,/root/.bash_profile
但当我未登录时这没有帮助。
CentOS 6.x
答案1
编辑您的脚本,并在 logwatch 调用之前/etc/cron.daily/0logwatch
添加。export DATE_MANIP=DM5
例子:
#!/bin/sh
#Set logwatch location
LOGWATCH_SCRIPT="/usr/sbin/logwatch"
#Add options to this line. Most options should be defined in /etc/logwatch/conf/logwatch.conf,
#but some are only for the nightly cronrun such as --output mail and should be set here.
#Other options to consider might be "--format html" or "--encode base64", man logwatch for more details.
OPTIONS="--output mail"
# Fix Date::Manip issue
export DATE_MANIP=DM5
#Call logwatch
$LOGWATCH_SCRIPT $OPTIONS
exit 0