• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved fail2ban issue

Dork

Regular Pleskian
Server operating system version
CentOS 7
Plesk version and microupdate number
18.0.49 Update #2,
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "delete from bans where timeofban < strftime('%s', 'now', '-7 days')"
has no effects
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "vacuum"
doesn't work.
am I doing something wrong?
 
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "delete from bans where timeofban < strftime('%s', 'now', '-7 days')"
has no effects
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "vacuum"
doesn't work.
am I doing something wrong?
Take a look here, it may help you:
 
Take a look here, it may help you:
Sorry - but excactly that doesn't work (see my question)
 
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "delete from bans where timeofban < strftime('%s', 'now', '-7 days')"
has no effects
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "vacuum"
doesn't work.
am I doing something wrong?

Your query seems right, although I haven't tested it. Note that you'll need the run the vacuum command directly after you've ran the query.

What is it you're trying to achieve exactly?
 
Your query seems right, although I haven't tested it. Note that you'll need the run the vacuum command directly after you've ran the query.

What is it you're trying to achieve exactly?
I`m on a virtual Server (Virtuozo) and the limit if numiptent is 2000.
Vey often the server is under havy attack (ssh, postfix) and the numiptent increases (> 2000).
In this case I have to delete the database table and the logfile by hand.
So I want to write a script that read the numiptent and start the "vacuum" if numiptent is > 1900.
The script should start via cronjob.
 
I don't need advice for writing the script - but as long as at least
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "vacuum;"
doesn't work, as long it's useless to write the script
 
I see. What I actually meant to ask was what do you expect the query to do?

The query DELETE FROM bans WHERE timeofban < STRFTIME('%s', 'now', '-7 days') deletes all records (bans) older than 7 days. Do you actually have fail2ban configured with a ban period longer than seven days? If you have shorter ban period there won't be anything in the database to delete when you run that query.
 
I see. What I actually meant to ask was what do you expect the query to do?

The query DELETE FROM bans WHERE timeofban < STRFTIME('%s', 'now', '-7 days') deletes all records (bans) older than 7 days. Do you actually have fail2ban configured with a ban period longer than seven days? If you have shorter ban period there won't be anything in the database to delete when you run that query.
Yes - I know
but
Code:
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "vacuum;"
should work independently of the other query - am I rght?
 
No, that's not what vacuum is used for. From How SQLite VACUUM Optimizes Your Database

The SQLite VACUUM command​

The VACUUM command does not change the content of the database except the rowid values. If you use INTEGER PRIMARY KEY column, the VACUUM does not change the values of that column. However, if you use unaliased rowid, the VACUUM command will reset the rowid values. Besides changing the rowid values, the VACUUM command also builds the index from scratch.

It is a good practice to perform the VACUUM command periodically, especially when you delete large tables or indexes from a database.

It is important to note that the VACCUM command requires storage to hold the original file and also the copy. Also, the VACUUM command requires exclusive access to the database file. In other words, the VACUUM command will not run successfully if the database has a pending SQL statement or an open transaction.
 
Last edited:
Yes, that's correct.
So I wil use a customized "delete" command as a part of my script and the "vacuum" command as an addition (in order to optimize the db).
Thanks for your help!

Please mark the thread as resolved.
 
Back
Top