
我最近經歷了一個日誌監視問題這是透過運行修復的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