First we are going to configure the Google Sitemap in Magente Admin and then we are going to log onto a Unix system via SSH and edit the crontab. And while we are at it, we are going to configure some additional, but important cronjobs. A cronjob is something like a scheduled task. The computer will execute that task at exactly the time or date you have configured. It is an automated process that will take routine tasks out of your hands.
Configuring Google Sitemap in Magento
First setup the cronjob in Magento:
In Magento Admin > System > Configuration > Catalog > Settings and configure:
- Enable
- Fill in the time to run the Cronjob. I prefer after midnight.
- Choose a frequency. Daily is best.
- Fill in a TO address. In case the Cronjob doesn't go well an error report will be sent..
- Fill in a FROM address for that mail.
- Choose a Email Template which will be used for the error report.
Now we setup the sitemap. I will keep in mind a sitemap setup for multiple stores.
- Add sitemap
- Filename HAS to be sitemap.xml. No variations are possible.
- Path. Last path folder has to be writable (777). I have used /sitemap/shopa/. As you can see, within the /sitemap/ folder, each Shop will have its own folder to put the sitemap.xml in.
- Choose the Shop View and Save.
- You can now create a sitemap.xml for each Shop View.
- When the Cronjob works without errors, you can see this in the Last Generated column.
Configuring Cronjob on a Linux Server using SSH.
We connect to our Linux Webservers using SSH. Login procedure can be configured in a great little application called Putty. More information can be found on their website: http://www.chiark.greenend.org.uk/~sgtatham/putty/
- Connect to the Host using a Hostname or IP address on Port 22 and connection type SSH. In the popup window you are asked for a login name and password. Great now we are on the server.
- Type and enter: "crontab -e" to open the crontab. Most likely this will be in an app called VI.
- Type "i" to change mode to "insert". Now you are able to edit the crontab.
- Now paste the following line:
*/15 * * * * php -f /var/www/vhosts/PATH/TO/MAGE/cron.php > /dev/null 2>&1
The /dev/ part means that all output (ok and errors) will be output in /dev/null/ folder.
The 15 * * * * means that this job will be run every 15 minutes. - Following line will reindex the database every day at 4 AM:
0 5 * * * php -f /var/www/vhosts/PATH/TO/MAGE/shell/indexer.php > /dev/null> 2>&1 - Following line will clean the log files every first of the month:
0 0 1 * * php -f /var/www/vhosts/PATH/TO/MAGE/shell/log.php clean > /dev/null 2>&1 - Hit "ESC" to exit "insert" mode.
- Enter "Shift+q", type "wq" and hit ENTER to exit the Crontab.
- When successful this message appears: "crontab: installing new crontab"
This concludes how to configure a cronjob on a Linux environment and within the Magento Admin. I have used this approach for my Magento based websites http://www.ruitersport-discounter.nl (equestrian budget) and http://www.paardcare.nl (equestrian) with success.