Under Group Management -> Adlists, the instructions note that the gravity database can be updated by typing "pihole -g"
I'd like to run this as a crontab but I'm not sure how. Since this is running as a container, that command is not recognized from the Raspberry Pi command line.
Any ideas on how to update pihole gravity on an automatic basis when it is running as a container?
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.
That doesn't supply an answer to your question: It just states that Pi-hole is handling periodic blocklist updates automatically.
No need to do this, there already is a preconfigured cron job updating once a week, as jfb has pointed out above.
If you'd insist on wanting to change that cron configuration, you could do so from inside the container. Refer to Docker's documentation on how to run a shell inside a container.
I would not recommend it, though: Any changes you apply to a Docker instance in that way will be lost on container restart.
Sorry if I'm being obtuse, but the documentation for the Docker Image states:
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.
Am I reading incorrectly that, at midnight, my container grabs the newest versions of my adlists?
This is what I was trying to solve for with respect to cron: a way to update the gravity database daily.
At midnight, the Pi-hole logs rotate. The cron for gravity update is on Sunday morning between 3 am and 5 am your local time. The Pi-hole cron scripts are here in a bare metal install (don't know if this is the same in docker).
Log rotation (happening daily) is different from a gravity list update (happening once a week).
By default, Pi-hole's normal blocklist update is once a week, which is sufficient, as blocklist updates don't occur on an hourly or even daily basis.
As said before, that update is controlled by cron which is incorporated into the container. In order to inspect that cron configuration, you'd have to access the respective files from within the container, also as mentioned before. You could also change the configuration files from within the container, but those changes wold be lost on container restart.
A Docker compatible way to define custom update frequencies would probably be to mount /etc/cron.d/ for your container from persistent storage, but you'd probably had to watch out getting file permissions right.
They say that CRON is baked in to update the adlist and do the log flush but then only talk about the logs being flushed at midnight (and don't mention grabbing the latest adlists).
That also explains why I wasn't seeing it updated.
That said, I was able to solve the problem by adding an entry at /etc/cron.daily that runs this:
Understood. You're correct. My initial post was how to update the gravity db automatically because it took me some time to realize it was automatic.
You are correct that there is no "problem" with the docker instance. The "problem" I was trying to solve was how to update the gravity db when I wanted it updated. I want to update the gravity db more than once a week and I don't want to have to use the web interface to do so manually so I was trying to figure out a way to do so via cron.
Consequently, I found out that adding a file to cron.daily as described did not work so I did an SSH into the device and added the following to the crontab: