Linux, Magento

Adding a Cron Job in Magento

Add the following lines to your module’s config.xml file under etc folder.

<crontab>

<jobs>

            <namespace_yourmodulename>

                <schedule><cron_expr>*/1 * * * *</cron_expr></schedule>

<run><model>navision/observer::methodToCall</model></run>

</namespace_yourmodulename>

</jobs>

</crontab>

 

Observer:

<?php

class Namespace_Yourmodulename_Model_Observer {

public static function methodToCall(){

//Code to Execute

Mage::log(“Cron Executed”);

}

}

?>

Note: Magento root file cron.php needs to be added to crontab on web server.

Read More...