Stündliche logrotation für fail2ban nach Größe einrichten
Zur Navigation springen
Zur Suche springen
- 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 /root/rotatefail2ban.sh
- 3. Script rotatefail2ban.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