Last active
March 30, 2021 15:59
-
-
Save tschifftner/ac09d17e8878ec89d930387050b4224b to your computer and use it in GitHub Desktop.
Clean fail2ban database from older entry - use script with cronjob!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Tobias Schifftner, @tschiffnter | |
# | |
# Usage: | |
# bash fail2ban-cleanup.php <fail2ban.sqlite3> | |
FILE=${1:-"/var/lib/fail2ban/fail2ban.sqlite3"} | |
[ -f "$FILE" ] || { echo "$FILE not found"; exit 1; } | |
function sql() { | |
$(which sqlite3) "$FILE" "$@" | |
} | |
sql "DELETE FROM bans WHERE timeofban < strftime('%s', 'now', '-7 days');" | |
sql "VACUUM;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment