Create Cron Jobs in Magento

Set up a cron job in magento module

Posted on March 15, 2016 in Magento, PHP

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:

                <schedule><cront_expr>* 17 * * *</cron_expr></schedule>

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:


class My_Module_Model_Observer 
    public function setStatus()

You will see string “Works!” adding to the system.log at 5:00PM everyday.

comments powered by Disqus