Testing cron jobs in Magento

24 May 2017 in Magento

At first, find out how the cronjob is called from the module's config.xml by looking at the /config/crontab/jobs/*/run/model XPath, eg:


On this example, you need to initialize the my_cronjob/observer model and call the method my_method on it. In order to do this create a file to run from command line with these contents:

// initialize magento application
require_once '/path/to/app/Mage.php';    

// initialize model and run the method
$myCronJob = Mage::getModel('my_cronjob/observer');