Want more timely Centmin Mod News Updates?
Become a Member

PHP-FPM How to auto update Geo IP Database? cron

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Oxide, Aug 14, 2015.

  1. Oxide

    Oxide Active Member

    534
    29
    28
    Mar 19, 2015
    Ratings:
    +59
    Local Time:
    7:37 PM
    Hello.


    How can I auto update "geoip_country_code_by_name" with a cron job or so?

    I found this on github in centmin.sh or so,
    # cp -a /usr/share/GeoIP/GeoIP.dat /usr/share/GeoIP/GeoIP.dat-backup
    # wget -cnv http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz -O /usr/share/GeoIP/GeoIP.dat.gz
    # gzip -df /usr/share/GeoIP/GeoIP.dat.gz

    would this work to be ran on first tuesday each month? (when maxmind updates it)

     
    Last edited: Aug 14, 2015
  2. eva2000

    eva2000 Administrator Staff Member

    54,894
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    7:37 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Code:
    #!/bin/bash
    \cp -f /usr/share/GeoIP/GeoIP.dat /usr/share/GeoIP/GeoIP.dat-backup
    wget -cnv http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz -O /usr/share/GeoIP/GeoIP.dat.gz
    gzip -df /usr/share/GeoIP/GeoIP.dat.gz
    this might work save to file i.e. geoip-update.sh and run it from cronjob
     
  3. Oxide

    Oxide Active Member

    534
    29
    28
    Mar 19, 2015
    Ratings:
    +59
    Local Time:
    7:37 PM
    Thank you.

    How often should I run the cron job, or how often does it update? I heard it updates each thursday.. but i see sites like Telize - JSON IP and GeoIP REST API relaying on same method, has more accurate IP.

    GeoLite Legacy Downloadable Databases « Maxmind Developer Site

    the one i use is geoip_country_code_by_name only, am i updating correct one?