Configuring Pi-Hole to update blocklists more regularly

By default Pi-Hole updates it's block lists once a week.

Broadly speaking, this is fine for blocking Ad domains (although the recent trend towards advertisers generating new domains does undermine that a bit).

But, if you've added a Phishing block list (as detailed in Building Your Own DNS over HTTPS Server), this is far less optimal - Phishing domains tend to do the majority of their damage during the first 24 hours, so only getting an update into the blocklist (potentially) 7 days later isn't much use.

In this post we'll walk through the (simple) procedure to have Pi-Hole update the gravity lists more frequently

 

Gravity updates are triggered via cron, in /etc/cron.d/pihole

grep updateGravity /etc/cron.d/pihole 
26 3   * * 7   root    PATH="$PATH:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log

As that crontab is a core file within Pi-hole we're not going to edit that file, otherwise any changes we make would be lost the next time Pi-Hole is updated.

echo '30 */2 * * *    root    PATH="$PATH:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log' > /etc/cron.d/update_gravity
systemctl restart cron

Lists will now be updated every 2 hours, at 30 mins past the hour.

 
 Share