1

I was working on a extension for our Magento website, but i found out that my cronjob is not working correctly.

Config: \app\code\local\Questcontrol\CustomExstention\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Questcontrol_CustomExstention>
            <version>0.1.0</version>
        </Questcontrol_CustomExstention>
    </modules>
    <global>
        <models>
            <CustomExstention>
                <class>Questcontrol_CustomExstention_Model</class>
            </CustomExstention>                         
        </models>
    </global>
    <crontab>
        <jobs>
            <CustomExstention>
                <schedule>
                    <cron_expr>* * * * *</cron_expr>
                </schedule>
                <run>
                    <model>CustomExstention/Observer::test</model>
                </run>
            </CustomExstention>
        </jobs>
    </crontab>
    <frontend>
        <routers>
            <CustomExstention>
                <use>standard</use>
                <args>
                    <module>Questcontrol_CustomExstention</module>
                    <frontName>CustomExstention</frontName>
                </args>
            </CustomExstention>
        </routers>
    </frontend>
</config>

Object: \app\code\local\Questcontrol\CustomExstention\Model\Observer.php

<?php
class Questcontrol_CustomExstention_Model_Observer {

    public function test(){
        Mage::log("TEST success");
    }
}
?>

What am i doing wrong at this point?

Thanks in advanced!

0

First of all, check your system crontab for magento cron. I think that magento cron.sh or cron.php runs every five minutes (cron expr: */5 * * * *), but not every minute (your cronjob expr), thats why you can't run your code propely.

Second problem can be logic of magento cron (cron.sh or cron.php) - when it runs, it checks cron_scheduler table and works with it, after that it add new events (and remove old, etc) from that table. May be your cronjob just runs later because of this logic.

And the third problem can be magento cron hangs on. In some cases (eg: your magento store has lots of cronjobs or cronjobs do lots of work, etc.) when your magento require a lot of time to work with cronjobs, cron.sh process can just hangs on and you need restart it.

pS: In one of our projects we added additional system for magento cron control and moved heaviest and longest operations to the system cron, instead of magento cron

  • Thanks for your fast respone, I tried to put the cron on every 5 minutes but this still doesn't work. I tried the second option as well, but this didn't make any different at all. As last i tried to completely restart my apache server to clear all running crons (still doesn't work). – LittleProgrammer Nov 1 '16 at 14:29
  • Just truncate table cron_scheduler and try run you job. By the way, you can check your job in this table, if job exists - all ok, it's just cron freeze, if not - try clean cache (config cache) and try to run your job – user32105 Nov 2 '16 at 14:10
  • I checked the 'cron_scheduler' table in my mysql database, but my cron is not in that table. I have cleaned and disabled the cache, but it still doesn't work. – LittleProgrammer Nov 3 '16 at 9:17
  • may be your module isn't active? Check app/etc/modules/<Module_Name>.xml active tag and check in core_reousrce DB table – user32105 Nov 3 '16 at 14:56

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.