Join the community today
Register Now

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

    503
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    6:52 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

    30,160
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,135
    Local Time:
    6:52 PM
    Nginx 1.13.x
    MariaDB 5.5
    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
     
    • Useful Useful x 1
  3. Oxide

    Oxide Active Member

    503
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    6:52 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?