fail2ban 的 Logrotate 错误

Err*_*ald 4 logrotate fail2ban

运行 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
Run Code Online (Sandbox Code Playgroud)

这是/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
}
Run Code Online (Sandbox Code Playgroud)

这是 /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
Run Code Online (Sandbox Code Playgroud)

use*_*517 8

错误无法联系服务器。它在运行吗?

你的 fail2ban 服务没有运行启动它!

service fail2ban start
Run Code Online (Sandbox Code Playgroud)

或者任何在你的 Ubuntu 上启动它的东西。