2

I have created cron jobs @ every 1 min to run. And I run the http://localhost/magento/cron.php. but it's not working.

My Code is:

Observer.php

<?php
class Easylife_CJobs_Model_Observer {
    public function setStatus() {
        Mage::log("Cron Jobs Working Fine!",null,"cronjobs");
    }
}

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_CJobs>
            <version>0.1.0</version>
        </Easylife_CJobs>
    </modules>
    <global>
        <models>
            <cjobs>
                <class>Easylife_CJobs_Model</class>
            </cjobs>
        </models>
    </global>
    <crontab>
        <jobs>
            <cjobs>
                <schedule>
                    <cron_expr>*/1 * * * *</cron_expr>
                </schedule>
                <run>
                    <model>Easylife_CJobs_Model_Observer::setStatus</model>
                </run>
            </cjobs>
        </jobs>
    </crontab>
</config>

Please let me know is this procedure is correct else is another procedure?

2 Answers 2

4

Model node should contain the model reference <model>cjobs/observer::setStatus</model> instead of a full class name.

Also make sure logging is turned on or put true as fourth argument to Mage::log() in order to force writing the "Cron Jobs Working Fine!" log.

2
  • Warning: include(): Failed opening 'Easylife\CJobs\Model\Easylife\CJobs\Model\Observer.php' Error is Came.
    – M_N
    Commented Apr 10, 2015 at 12:22
  • I have modified config.xml file. now working fine. Thank You.
    – M_N
    Commented Apr 10, 2015 at 12:24
2

My advice is also look at cron_schedule table if you debug cron. If you did it you could understand that the problem is following:

exception 'Mage_Core_Exception' with message 'Invalid model/method definition, expecting "model/class::method".' in /var/www/local.dev/www/mg18com/app/Mage.php:595

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.