Magento cron job not working

2019-09-06 12:42发布

问题:

I have configured cron job in my admin's custom module in magento but cron job is not working.Nothing in my magento->var->log->system log file.below is my full module details:.

JR->CreateAdminController->etc->config.xml

<?xml version="1.0"?>
<config>
<modules>
    <JR_CreateAdminController>
        <version>1.0.0</version>
    </JR_CreateAdminController>
</modules>
<global>
    <helpers>
        <jr_createadmincontroller>
            <!-- Helper definition needed by Magento -->
            <class>Mage_Core_Helper</class>
        </jr_createadmincontroller>
    </helpers>
</global>
<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <jr_createadmincontroller before="Mage_Adminhtml">JR_CreateAdminController_Adminhtml</jr_createadmincontroller>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
<adminhtml>
<layout>
    <updates>
  <petra>
      <file>createadmincontroller.xml</file>
     </petra>
 </updates>   
</layout>
</adminhtml>
<!-- ++++++++++++CRON JOB CODE++++++++++++ -->
<crontab>
    <jobs>
        <jr_createadmincontroller>
            <schedule><cron_expr>* * * * *</cron_expr></schedule>
            <run><model>createadmincontroller/observer::setStatus</model></run>
        </jr_createadmincontroller>
    </jobs>
</crontab>
</config>

JR->CreateAdminController->Model->Observer.php

<?php
class JR_CreateAdminController_Model_Observer {
public function setStatus() {
    echo "let see!!!";
    Mage::log("WORKS!");
 }
 }
?>

Why Mage::log not write any thing in my log file and also how will i check my cron is running or not. pLease help me out !!!!

回答1:

You don't declare your models in your config.xml but observer is a model. You should add

<models>
        <jr_createadmincontroller>
            <class>JR_CreateAdminController_Model</class>
        </jr_createadmincontroller>
    </models>

In the global node. And change this

<run><model>createadmincontroller/observer::setStatus</model></run>

By this:

<run><model>jr_createadmincontroller/observer::setStatus</model></run>


标签: php magento cron