Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 )

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 {

    rotate 4

    fail2ban-client set logtarget /var/log/fail2ban.log >/dev/null

    # 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


# 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
    [ -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
up vote 5 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

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

Your Answer


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.