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'' :…“)
 
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
;1. logrotation Konfiguration anlegen in Datei  '''''/etc/logrotate.d/fail2ban''''':  
;1. logrotation Konfiguration anlegen in Datei  '''''/etc/logrotate.d/fail2ban''''':  


:''/var/log/fail2ban.log {''
:''/var/log/fail2ban.log {''
Zeile 27: Zeile 26:
:''* */1 * * * /root/rotatefail2ban.sh''
:''* */1 * * * /root/rotatefail2ban.sh''


;3. Folgenden Inhalt in dem Script ablegen:  
;3. Script fail2ban.sh unter /root/ anlegen und folgenden Inhalt in dem Script ablegen:  


:''#!/bin/sh''
:''#!/bin/sh''

Version vom 10. Oktober 2018, 00:38 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. Script fail2ban.sh unter /root/ anlegen und 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