Stündliche logrotation für fail2ban nach Größe einrichten: Unterschied zwischen den Versionen

Aus Glaskugel
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „;1. logrotation Konfiguration anlegen in Datei '''''/etc/logrotate.d/fail2ban''''': :''/var/log/fail2ban.log {'' : ''size 2000M'' : ''rotate 7'' :…“)
(kein Unterschied)

Version vom 9. Oktober 2018, 23:37 Uhr

1. logrotation Konfiguration anlegen in Datei /etc/logrotate.d/fail2ban


/var/log/fail2ban.log {
size 2000M
rotate 7
compress
missingok
notifempty
postrotate
/usr/bin/fail2ban-client flushlogs >/dev/null || true
endscript
}


2. Cronjob erstellen
* */1 * * * /root/rotatefail2ban.sh
3. Folgenden Inhalt in dem Script ablegen
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.d/fail2ban >/dev/null 2>&1
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
4. File Rechte auf ausführbar setzen
chmod +x /root/rotatefail2ban.sh