Matomo downloads database file from https://download.db-ip.com every hour (same time as console archive job is executed) instead of scheduled period (week or month).
Matomo download geoip db on scheduled period week or month.
Matomo download geoip db every hour.
Setup automatic geo ip download for DBIP / GeoIP 2 (Php)
@kvas11 Thanks for creating this issue. I'll try to investigate this.
Are you able to see if the geoip database file in misc folder is actually updated?
Maybe it fails updating that file and fails silently and so tries to update it again with the next run
You are probably right, the 'DBIP-City.mmdb' file was last changed at September 9 - probably due to lack of write file permissions. I just set the correct file permission to the user, who's cron is executing archive job and will let you now if something changed.
Thanks for the help
Ah, that might be a "typical" issue. If you set up GeoIP via the UI, it downloads the file with the webserver user. If your cron runs with another user, it might not be able to write the file...
Sorry for the "false alarm", everything is OK now, Db file was correctly downloaded and the message in the UI says: "It is next scheduled to run on 2021-12-01".
Maybe some warning message about the errors during file update could be useful, similar like "System check" messages.
@kvas11 didn't the run of the scheduled task return an error or warning, that indicated that the file couldn't be written?
No, I could not find any info/error/warning about failed db update process in matomo cron job log
Just checked that locally, and when the file is not writable the task actually outputs this:
INFO [2021-11-22 17:11:01] 24193 Scheduler: executing task Piwik\Plugins\GeoIp2\GeoIP2AutoUpdater.update... INFO [2021-11-22 17:11:01] 24193 Downloading https://download.db-ip.com/free/dbip-city-lite-2021-11.mmdb.gz to /srv/matomo/tmp/latest/DBIP-City.mmdb.gz.download. INFO [2021-11-22 17:11:24] 24193 GeoIP2AutoUpdater: successfully downloaded 'https://download.db-ip.com/free/dbip-city-lite-2021-11.mmdb.gz' WARNING [2021-11-22 17:11:25] 24193 /srv/matomo/plugins/GeoIp2/GeoIP2AutoUpdater.php(339): Warning - copy(/tmp/DBIP-City.mmdb): failed to open stream: Permission denied - Matomo 4.6.0-rc2 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) INFO [2021-11-22 17:11:25] 24193 GeoIP2AutoUpdater: successfully updated GeoIP 2 database 'https://download.db-ip.com/free/dbip-city-lite-2021-11.mmdb.gz'
So for me, there is an error displayed
Stefan, you are right, when I fixed file/dir permissions, DB update process output was logged in cron log file. Now I would like to test it again with missing write permissions. How do I force GeoIP2AutoUpdater again in the next run? In Matomo UI, there are just 2 options (week, month).
@kvas11 There should be a database record in
option table with
option_name = geoip2.updater_last_run_time. Setting that one to 0, should indicate the downloader when it was last updated.
Btw. You can also directly run the task using
./console scheduled-tasks:run "Piwik\Plugins\GeoIp2\GeoIP2AutoUpdater.update"
Stefan, it works like described in your comment above. I apologize for stealing your time. Please, close this issue.
No problem. Good to hear it works as expected.