3 simple steps to setup cronjobs on server and create custom task in your Magento instance.
- Setup cronjob on server
crontab -e
and then
#cron.sh will run every 5 minutes */5 * * * * /bin/sh /path/to/magento/cron.sh
- Add definition of cron job in app/code/local/K2Service/Cron/etc/config.xml of your module
<?xml version="1.0"?> <config> <modules> <K2Service_Cron> <version>1.0.0</version> </K2Service_Cron> </modules> <global> <models> <k2_cron> <class>K2Service_Cron_Model</class> </k2_cron> </models> </global> <crontab> <jobs> <k2_cron_job> <schedule> <cron_expr>*/10 * * * *</cron_expr> </schedule> <run> <model>k2_cron/observer::job</model> </run> </k2_cron_job> </jobs> </crontab> </config>
- Create Observer in app/code/local/K2Service/Cron/Model/Observer.php
<?php class K2Service_Cron_Model_Observer { /** @return void */ public function job() { Mage::log("Custom Cron Job Works"); } }
Related posts:
How to Set Up Admin Dashboard
Setting Up Your Admin Dashboard
After downloading and installing Magento, the next step is the Da...
Formatted price without currency symbol
Sometimes you need to display get formatted price (for example on custom grids in admin ) but withou...
How To Install A Magento Theme
How To Install A Magento Theme
Installing a Magento theme is not as easy as you would have loved ...
How to get all Store Ids in Magento
If you want to get all IDs of available store views in your Magento store you can just use this code...