Background
Pi-hole Gravity is the database that contains all the blocked domains, by default, this is set to update every Sunday between 3-5 am. You may want to update this database more frequently to ensure you have all the latest domains, especially ones the related to malware and phishing.

This guide is aimed at both standard and docker installations of Pi-hole.

Setup
To achieve this, cron will be used to schedule the task every day.

  1. sudo crontab -e

  2. Select option 1 (if promted)

  3. Add one of the following lines

Docker:
0 5 * * * sudo docker exec -it pihole_container_name pihole updateGravity >/dev/null 2>&1 - This will run every day at 5 am.

Standard Install:
0 3 * * * sudo pihole updateGravity >/dev/null 2>&1 - This will run every day at 3 am.

Flush Pi-hole logs every day
Docker:
0 0 * * * sudo docker exec -it pihole_container_name pihole flush >/dev/null 2>&1

Standard Install:
0 0 * * * sudo pihole flush >/dev/null 2>&1

These will clear the logs every day at midnight.


Cover Image Credit: https://unsplash.com/photos/2YWS62tLATA