Gravity update, when does it run exactly?

I have checked /etc/cron.d/pihole and the update has been set to 4am on a Sunday.

00 4   * * 7   root    PATH="$PATH:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log

I have created a /etc/cron.d/pihole-extra to do a second update for Wednesday 4am.

00 4   * * 3   root    PATH="$PATH:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log

When I hoover over the Blocklist tab on the web interface it says last update 20:20 ago which is 3.13pm last Wednesday. If I check the modified date on the file /etc/pihole/gravity.list it says 3.13pm last Wednesday as well.

Though if I check the last modified date of /var/log/pihole_updateGravity.log it says 4.01am last Wednesday. Which should be the correct time (cron runs at 4am).

I'm a bit confused now. Why does the hoover say something different?
When does my Gravity update run now exactly?

Your gravity update begins at the time specified in the cron. The one installed by Pi-Hole is randomly selected between 3 am and 5 am your local time, and is randomly different for all Pi-Holes to equalize server loads.

Your system log for that day (located in /var/log) will show which cron scripts ran when. On my system the following appears in the Sunday log:

May 19 03:46:01 Pi-3B CRON[5047]: (root) CMD ( PATH="$PATH:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log)

If you did a manual rebuild, or a repair, or an update then, this would be the correct time. This would not be written to the updateGravity log. The time shown is when the gravity list was changed.

Make sure you reload the page to get the updated information.

I know the standard cron is random. I just changed it to 4am (instead of the random 4.23am) it was before.

I did for sure reload/refresh the page multiple times.
To make it even more strange it now says: last updated 01.57 ago
I did not do a manual update...

The time shown on the web interface is the last modification date of /etc/pihole/gravity.list, as you found out. If that time changes, then so will the time shown on the web interface.

1 Like

Thanks @Mcat12
But how can the file being changed and thus show it on the web interface without doing a manual update or through a cron update?

pi@noads:~ $ date
Fri 24 May 15:04:58 CEST 2019

pi@noads:~ $ stat /etc/pihole/gravity.list
Access: 2019-05-20 01:50:59.456646090 +0200
Modify: 2019-05-20 01:50:59.766633105 +0200
Change: 2019-05-20 01:51:03.406480636 +0200

pi@noads:~ $ sudo touch /etc/pihole/gravity.list
pi@noads:~ $

pi@noads:~ $ stat /etc/pihole/gravity.list
Access: 2019-05-24 15:05:28.432883839 +0200
Modify: 2019-05-24 15:05:28.432883839 +0200
Change: 2019-05-24 15:05:28.432883839 +0200

image

Any modification to the file, such as touch will change the date. I can't tell you why your system is modifying the file, that is outside of Pi-hole.

2 Likes

Just leave it alone, unless you know what you're doing! You're just going to ruin your Pi-hole experience pretty quick...

Guys, Iā€™m not using touch at all...

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.