IP2Location is one of the top IP database provider in the world as their database is being updated every 1st day of the month, in order to make use the latest database to keep data up to date, we may need to download, extract and import the database to our system.
Thanks for the automation features, where we can easily schedule the download using the Cronjob, than use the shell script to automate this task to save our life.
This post only work for the paid customer where already subscribe their service, only with the Download Token given, than only you able to do the automation.
For those paid customer, you may login to your IP2Location account, than go to Download page, from here, you may get your Download Token.
- Download the automation package from https://www.ip2location.com/downloads/automated-ip2location-bin-download-linux.zip
- Decompress and edit the download-ip2location-bin.sh with any text editor.
- Search for TOKEN=”DOWNLOAD_TOKEN” and replace the “DOWNLOAD_TOEKN” with your token.
- Search for CODE=”DB24BIN” and replace with the code found in the download page. If you wish to check for both IPv4 and IPv6 database, just download the IPv6 will do, as it’s already include both database inside.
- Search for DBPATH=”YOUR_DATABASE_LOCATION” and replace the “YOUR_DATABASE_LOCATION” with your database path
- Test the script by running ./download-ip2location-bin.sh. The database in the given path should be replace with the latest version from IP2Location.
- Once everything is ready and working fine, you may setup the cronjob for the monthly updates.
- Add the following line into the end of your content. The following line means it will execute the download and update at 0815 on the 1st of every calendar month.
15 8 1 * * bash /path/to/download-ip2location-bin.sh