CiviCRM provides a command-line script which will retrieve latitude and longitude for a specified set of contact records using your configured Mapping Provider.
Before running this script you must:
You can run the script from a URL or from the shell. More information on calling this (and other similar commands) available on the command line interface configurationpage.
Username, password and key are required parameters. Optionally, you can pass two variables with the start and end ids of the contacts that you want to geocode. If you exclude these parameters, the script will geocode all contacts who don't already have a latitude/longitude value stored.
Here's an example for Drupal:
and for Joomla!:
If you have cause to set this up as a cronjob, see the instructions at for setting up a secure wget invocation "Security Note" in the context of civicmail at http://wiki.civicrm.org/confluence/display/CRMDOC/CiviMail+Installation.