Archives
September 2010 (1)March 2010 (1)
January 2010 (1)
November 2009 (1)
July 2009 (1)
January 2009 (3)
December 2008 (1)
Sections
Code Tutorial (4)Misc (2)
QRCode Button (1)
Server Admin (2)
Os
Debian (1)Code Tags
PHP (3)Mysql (1)
Bash (1)
Tools
Show/Hide Keys
Code Tags: bash
I needed to keep my GeoIP db up to date for my stats package so I decided to write a cron script that would do it for me.
Place the above code (or download here http://blogs.bluerhinos.co.uk/data/files/9/geoipupdate ) into /etc/cron.monthly/geoipupdate
Note: they update their db on the 1st or 2nd so I changed my /etc/crontab so that the monthly scrips run on the 3rd
I needed to keep my GeoIP db up to date for my stats package so I decided to write a cron script that would do it for me.
bash code:#!/bin/bash
#############################################################
# ./geoipupdate = Auto updates the free GeoIP databases
# (c) andrew[at]bluerhinos.co.uk 2010 : Creative Commons
#############################################################
#list of urls
URLS=" http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
URLS="$URLS http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
#target directory
TARGETDIR="/var/lib/GeoIP"
for URL in $URLS
do
wget -q -N -P "$TARGETDIR" "$URL"
BASENAME=`basename "$URL"`
gunzip -f "$TARGETDIR/$BASENAME";
done
Place the above code (or download here http://blogs.bluerhinos.co.uk/data/files/9/geoipupdate ) into /etc/cron.monthly/geoipupdate
Note: they update their db on the 1st or 2nd so I changed my /etc/crontab so that the monthly scrips run on the 3rd