Command Line to update Gravity DB when using pi-hole as a docker container

I'm running pi-hole as a docker container based on this registry: Docker Hub

In the documentation, regarding updating Ad Lists, it reads:

Automatic Ad List Updates - since the 3.0+ release, cron is baked into the container and will grab the newest versions of your lists and flush your logs. Set your TZ environment variable to make sure the midnight log rotation syncs up with your timezone's midnight.

While the logs are flushed weekly, the adlists are only updated weekly. I wanted a way to update the adllists every day at 6 am via cron.

Later on in the documentation, it also notes that the command to update the gravity db using the command line is as follows:

docker exec pihole_container_name pihole updateGravity

I SSH into my Raspberry Pi and run the command:

crontab -e

I then added the following line:

0 6 * * * docker exec Pihole pihole updateGravity

Again, Pihole is the name of my docker image. If your docker image is called something else then you substitute that name in the above.

So, when you're done, you'll have a way to update the gravity DB daily and twice on one day of the week (since a weekly update is already built in).

1 Like

Came accross this and it is a timesaver for me. Thanks!