Stündliche logrotation für fail2ban nach Größe einrichten: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 20: | Zeile 20: | ||
:''}'' | :''}'' | ||
;2. Cronjob erstellen | ;2. Cronjob erstellen | ||
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