php - 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);
}
}
解决方案
config.xml
请尝试在您的文件中使用以下代码。<crontabs>
我刚从<crontab>
<crontab>
<jobs>
<rewards>
<schedule>
<cron_expr>* * * * *</cron_expr>
</schedule>
<run>
<model>rewards/observer::sendEmails</model>
</run>
</rewards>
</jobs>
</crontab>
推荐阅读
- api - 如何验证 Analytics 360 是否与 BigQuery 成功关联?
- regex - 使用 4 个或更少 OR 语句的数字 -25 到 1045 的正则表达式
- regex - 使用 RegEx 匹配带有和不带有转义字符的字符串
- next.js - 下一个 js 零配置中的模块解析失败
- sql - 来自 SQL Server Management Studio 的令人困惑的性能建议
- arduino - 使用带有 DTH11 的 Arduino ATmega328P ADC 读取温度
- django - POST 和 GET 请求的不同序列化程序,这是正确的方法吗?动态嵌套序列化器
- python - 改进代码:在中间件中单击时显示 url 的日期时间
- selenium-ide - 如何读取输出字符串的一部分并将其与 seleniumIDE 中的存储变量进行比较
- c# - 由于包 ZedGraph 不兼容,无法运行包 EmguCV