首页 > 解决方案 > cron 作业未在自定义 magento 模块中运行

问题描述

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

我在模块的 config.xml 中添加了 crontab,并在模型中添加了观察者类

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

在 crontab 中也进行了条目,该条目在根位置有 cron.sh 文件的条目

因此,我被困在如何从这里走得更远并让它发挥作用。

配置文件

<?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>

观察者.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);
            }
}

标签: phpmagentocronmagento-1.9

解决方案


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

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

推荐阅读