In this example, I use My_Module as an example to show how to add cron job in Magento.
First let magento know about the cron job in config.xml, shown as below:
0.1.0 My_Module_Model * 17 * * * my_module/observer::setStatus
We will set up setStatus() method in app/code/local/My/Module/Model/Observer.php run at 5:00PM every day.
Next we add setStatus() method as following:
#app/code/local/My/Module/Model/Observer.php class My_Module_Model_Observer { public function setStatus() { Mage::log('Works!'); } }
You will see string “Works!” adding to the system.log at 5:00PM everyday.