运行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
错误无法联系服务器。 它运行吗?
你的fail2ban服务没有运行启动它!
service fail2ban start
或者在你的Ubuntu上启动它。
将“notifempty”添加到/etc/logrotate.d/fail2ban。 如果fail2ban已安装但未运行,日志将为空,不会被旋转。