B-219 Sec-55 Noida, India

How to create custom cron job in magento

Magento default have a cron.php file located in the root directory. To set a cron in magento you have to create your own module first, and in the config.xml you have to declare the method which will fired and the time. Below is a dump of a etc/config.xml file of a custom cron module

    <?xml version=“1.0??>
    <cron_expr>01 00 * * *</cron_expr>

As per mentioned in this xml your cron will be fired every day @ night 00:01 min

Now you have to write your own functionality in your module Model file, Here my model file name is Expired and the function which will trigger is productExpired().

    class Wl_Cronset_Model_Expired extends Mage_Core_Model_Abstract
    public function productExpired()
    // Your code goes here

Now login to your server to call the magento root cron.php and set to be fired in every minute.

(Visited 82 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.