自动更新GeoIP数据库

#!/bin/bash
if [ ! -d /usr/local/share/GeoIP ];then
    mkdir /usr/local/share/GeoIP
fi

if [ ! -d /usr/local/share/qqIP ];then
    mkdir /usr/local/share/qqIP
fi

wget -t 5 -O /tmp/GeoIP.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget -t 5 -O /tmp/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget -t 5 -O /tmp/GeoIPASNum.dat.gz http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz

gzip -df /tmp/GeoIP.dat.gz
gzip -df /tmp/GeoLiteCity.dat.gz
gzip -df /tmp/GeoIPASNum.dat.gz

mv -f /tmp/Geo*.dat /usr/local/share/GeoIP/

脚本名可任意取,比如update_geoip.sh,然后添加定时任务,每隔5天执行一次。

posted @ 2017-05-12 19:59  道霖  阅读(7165)  评论(0编辑  收藏  举报