Filed Under: SSH

Update GeoIP.dat automatically

9 June 2009 No Comment

Some of you will use GeoIP for geotargeting (a tutorial about this will follow).

One of the few things you’d have to manually if there was no cronjob, is to update the GeoIP.dat regularly.

Put this little sh script into cron.daily and it will be updated automatically:

#!/bin/bash
 
UNGZIPPED_FILE=GeoIP.dat
GZIP_FILE=GeoIP.dat.gz
REMOTE_PATH=http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/
LOCAL_PATH=/tmp/
LOCAL_FINAL_PATH=/www/vhtdocs/geo_ip/ #update this to your directory of choice
 
cd $LOCAL_PATH
wget -N -q $REMOTE_PATH$GZIP_FILE
gunzip $GZIP_FILE
cp -f $UNGZIPPED_FILE $LOCAL_FINAL_PATH$UNGZIPPED_FILE
 
exit






Like our posts? Then subscribe via Mail:

Email:  

Similar Posts:

Socialize:

delicious stumbleupon

Leave your response!

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.com.