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:
Add a total row in admin grid Magento
Magento has possibility to add total row in any grid in admin panel. You just need to use some addit...
Check if you are in Admin area
Simple piece of code for checking are you on admin area or on frontend
<?php
if (Mage::a...
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 ...
What is Magento?
Magento is one of the most powerful content management system available today and it has a wide use....