Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I get the following error when running a cron job, and I'm not too sure how to go about fixing. This is on 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

Here is the contents of /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
}

Here is the /etc/cron.daily/logrotate file

#!/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
share|improve this question
    
change this line fail2ban-client set logtarget /var/log/fail2ban.log >/dev/null to fail2ban-client set logtarget /var/log/fail2ban.log >/tmp/fail2banclient.out and then run logrotate and tell us what gets put in /tmp/fail2banclient.out –  Iain May 19 '13 at 19:52
    
@lain I still seem to get the same error: error running non-shared postrotate script for /var/log/fail2ban.log of '/var/log/fail2ban.log ' –  Errol Fitzgerald May 19 '13 at 20:13
    
@lain The contents of the /tmp/fail2banclient.out are ERROR Unable to contact server. Is it running? –  Errol Fitzgerald May 19 '13 at 20:14
add comment

2 Answers

up vote 3 down vote accepted

ERROR Unable to contact server. Is it running?

Your fail2ban service isn't running start it!

service fail2ban start

or whatever starts it on your Ubuntu.

share|improve this answer
    
+1 For the smugly comment on Ubuntu ... –  cept0 May 19 '13 at 20:28
    
@cept0: Wasn't a dig at Ubuntu. Who knows what someone who can't read an error message has done to their system ;) –  Iain May 19 '13 at 20:36
add comment

Add "notifempty" to /etc/logrotate.d/fail2ban. If fail2ban is installed but not running the log will be empty and will not be rotated. 

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.