Automatic log wipe

Hi all,
I'm pretty new to Pi-Hole (as well as Raspi) and I'm very glad that something like this exists.
One thing I'm missing is some kind of wiping my old logs (e.g. older than 24 hours) because I don't ever check if something weird was happening. Mostly I have the admin panel open and see if something was blocked I needed or something went nuts (like Geforce Experience).
In the settings itself I can disable logging completely or partially, but I want full logging for X hours (or days) and everything older can be deleted.

Best regards
Jochen

You can do that now with logrotate. We include a template file that you can modify to only keep as much data as you'd like. /etc/pihole/logrotate

Oh, I wasn't aware of that.
I'll check, thank you :slight_smile:

Retained query data is kept in two places.

The long term database is at /etc/pihole/pihole-FTL.db. By default, information is kept here for 365 days. You can change this to as little as 0 (disables the database), or in the case you are looking for, 1 day.

Use the MAXDBDAYS paramater here: Configuration - Pi-hole documentation

dnsmasq query logs are kept in /var/log. These are rotated nightly and six total days are maintained. Today and yesterday are uncompressed, and the previous days are compressed.

ls -lha /var/log/pihole.log*
-rw-r--r-- 1 pihole pihole 1.3M May 25 11:19 /var/log/pihole.log
-rw-r--r-- 1 pihole pihole 2.0M May 25 00:00 /var/log/pihole.log.1
-rw-r--r-- 1 pihole pihole 148K May 24 00:00 **/var/log/pihole.log.2.gz**
-rw-r--r-- 1 pihole pihole 174K May 23 00:00 **/var/log/pihole.log.3.gz**
-rw-r--r-- 1 pihole pihole 203K May 22 00:00 **/var/log/pihole.log.4.gz**
-rw-r--r-- 1 pihole pihole 150K May 21 00:00 **/var/log/pihole.log.5.gz**

If this amount of log retention is acceptable, then change nothing. Otherwise, as noted above, you can change the logrotate script.

I guess this is what I was looking for, I'll set it to 2 or 3 - so I have a few days in case I was out during the weekend or on a business trip (well after all that virus stuff) :wink: