自定义 magento 模块中的 cron 作业不是 运行

cron job not running in custom magento module

我正在我的自定义 magento 模块中添加一个 cron 作业。 但是 magento 没有执行我的 cron 作业

我在模块 config.xml 中添加了 crontab,并在模型

中添加了观察者 class

我什至尝试检查显示 cron 作业条目的 core_schedule table,但我的特定 cron 作业似乎丢失了。

还在 crontab 中进行了输入,在根位置有 cron.sh 文件的条目

因此,我一直在思考如何进一步改进并使其发挥作用。

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Uf_Rewards>
            <version>2.0.3</version>
        </Uf_Rewards>
    </modules>
    <frontend>
        <routers>
            <rewards>
                <use>standard</use>
                <args>
                    <module>Uf_Rewards</module>
                    <frontName>rewards</frontName>
                </args>
            </rewards>
        </routers>
        <layout>
            <updates>
                <rewards>
                    <file>rewards.xml</file>
                </rewards>
            </updates>
        </layout>
    </frontend>
    <global>
        <models>
            <rewards>
                <class>Uf_Rewards_Model</class>
                <resourceModel>rewards_resource</resourceModel>
            </rewards>
            <rewards_resource>
                <class>Uf_Rewards_Model_Resource</class>
            </rewards_resource>
        </models>
        <blocks>
            <rewards>
                <class>Uf_Rewards_Block</class>
            </rewards>
        </blocks>

    </global>
    <crontabs>
        <jobs>
            <rewards>
                <schedule>
                    <cron_expr>* * * * *</cron_expr>
                </schedule>
                <run>
                    <model>rewards/observer::sendEmails</model>
                </run>
            </rewards>
        </jobs>
    </crontabs>
</config>

Observer.php:

<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Uf_Rewards_Model_Observer extends Mage_Core_Model_Abstract
{
    public function sendEmails(){
        Mage::log('************************cron job*****************',NULL,'orderd.log',TRUE);
            }
}

请在您的 config.xml 文件中尝试使用以下代码。我刚刚从 <crontabs> 更改为 <crontab>

<crontab>
    <jobs>
        <rewards>
            <schedule>
                <cron_expr>* * * * *</cron_expr>
            </schedule>
            <run>
                <model>rewards/observer::sendEmails</model>
            </run>
        </rewards>
    </jobs>
</crontab>