1

i am trying to run a custom cronjob, however it doesn't seem to do anything. cron.php is running (is on crontab and writes to log after modification).

The cron_schedule table has entries, but doesn't list the cronjob of my module. I also cleared the cache.

Here is the part of my xml dealing with the cronjob:

<global>
    <models>
        <vendor_foobar>
            <class>Vendor_FooBar_Model</class>
        </vendor_foobar>
    </models>

    <crontab>
        <jobs>
            <vendor_foobar>
                <schedule>
                    <cron_expr>* * * * *</cron_expr>
                </schedule>
                <run>
                    <model>vendor_foobar/observer::checkFoo</model>
                </run>
            </vendor_foobar>
        </jobs>
    </crontab>
</global>

There is a path Vendor/FooBar/Model in app/local and it has a file called Observer.php with a class called Vendor_FooBar_Model_Observer:

class Vendor_FooBar_Model_Observer {
   public function checkFoo(){
       # ...
   }
}

I tried various things to make the effect of checkFoo visible: Writing to logs, throwing an exception, even sending an email. But it doesn't seem to be called at all, which fits the observation, that it isn't listed in cron_schedule.

Maybe there is something wrong with my code, maybe there is some requirement i am missing. But if not: Where in the core can i put debugging points to show what is going wrong? The mechanism indicated in cron.php seems a bit cryptic :/

0

The <crontab> node should not be inside the <global> node.

Your config.xml should look as follows.

<global>
    <models>
        <vendor_foobar>
            <class>Vendor_FooBar_Model</class>
        </vendor_foobar>
    </models>
</global>
<crontab>
    <jobs>
        <vendor_foobar>
            <schedule>
                <cron_expr>* * * * *</cron_expr>
            </schedule>
            <run>
                <model>vendor_foobar/observer::checkFoo</model>
            </run>
        </vendor_foobar>
    </jobs>
</crontab>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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