Automated Pi-Hole Updates

A couple of weeks ago, I posted about a new tool I had added to my network in order to actively block and eliminate adds. Pi-Hole in my case is running on an Ubuntu VM located on our FreeNAS media server, though it will likely eventually live on my 3d printer Raspberry Pi. However, as frequently as the advertising space seems to evolve, I wanted a way to automatically update the block lists, and stay current with the standard settings.

Enter Cron, the job scheduler on Linux. The cronjob itself is trivial, just run the “pi-hole -up” command once a night or once a week as desired. The more complicated piece was configuring email forwarding, so that I am notified each time the script runs, and can validate the updates.

For the email, I referenced the AskUbuntu thread at https://askubuntu.com/questions/536766/how-to-make-crontab-email-me-with-output, specifically the posting by Duli. This made it rather trivial, and Gmail was functional on the first try.

For the actual update cron, I used the following (running nightly at 1 AM), though I will likely reduce it to only once per week once I validate that the script is working correctly:

0 1 * * * /usr/local/bin/pihole -up

Discover more from Halfling13 Hobbies

Subscribe now to keep reading and get access to the full archive.

Continue reading