fail2ban 的 Logrotate 错误

fail2ban 的 Logrotate 错误

运行 cron 作业时,我收到以下错误,我不太清楚如何修复。这是在 Ubuntu 12.04 LTS 上。

test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

/etc/cron.daily/logrotate:
error: error running non-shared postrotate script for /var/log/fail2ban.log of '/var/log/fail2ban.log '
run-parts: /etc/cron.daily/logrotate exited with return code 1

以下是 /etc/logrotate.d/fail2ban 的内容

/var/log/fail2ban.log {

    weekly
    rotate 4
    compress

    delaycompress
    missingok
    postrotate
    fail2ban-client set logtarget /var/log/fail2ban.log >/dev/null
    endscript

    # If fail2ban runs as non-root it still needs to have write access
    # to logfiles.
    # create 640 fail2ban adm
    create 640 root adm
}

这是 /etc/cron.daily/logrotate 文件

#!/bin/sh

# Clean non existent log file entries from status file
cd /var/lib/logrotate
test -e status || touch status
head -1 status > status.clean
sed 's/"//g' status | while read logfile date
do
    [ -e "$logfile" ] && echo "\"$logfile\" $date"
done >> status.clean
mv status.clean status

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf

答案1

错误无法连接服务器。服务器正在运行吗?

您的 fail2ban 服务尚未运行,请启动它!

service fail2ban start

或者在你的 Ubuntu 上启动它的任何程序。

答案2

将“notifempty”添加到 /etc/logrotate.d/fail2ban。如果安装了 fail2ban 但未运行,则日志将为空,并且不会轮换。 

相关内容