Fail2Ban - Daily Yesterday summary


his tutorial works for CentOS only. For your specific OS tutorial use the tags or serach function in the sidebar area.


Today we take care of a script that sends an e-mail daily with a summary of banned hosts previous day by Fail2ban (useful along with Logwatch)

Of course if you don't you should have outgoing mail service configured already.

You may check:
Set-up sending mail via gmail account


Setup Postfix + Dovecot + Roundcube (almost a mailserver)

So, we create a file (script) called

$ cd /root/

$ touch

$ chmod 0755

$ chmod x

$ nano

Copy and paste below source code, change to your mail.

Test it by typing:

$ ./

Check e-mail.

If you get:

$ ./
Null message body; hope that's ok

means that no hosts were banned yesterday and empty mail is sent.

You can add this script to Cron task to perform daily

To do this simply move whole script to Cron daily directory:

$ mv /etc/cron.daily/