【问题标题】:Cron Schedule not working for custom moduleCron 计划不适用于自定义模块
【发布时间】:2018-04-19 21:19:26
【问题描述】:

我有一个自定义模块,它有两个 cron 计划。下面是模块的config.xml的代码

<?xml version="1.0"?>
<config>
  <modules>
    <Inchoo_Test>
      <version>0.1.0</version>
    </Inchoo_Test>
  </modules>
    <blocks>
        <test>
            <rewrite>
                <test>Inchoo_Test_Block_List</test>
            </rewrite>
        </test>
    </blocks>
  <global>
    <helpers>
      <test>
        <class>Inchoo_Test_Helper</class>
      </test>
    </helpers>
    <models>
      <test>
        <class>Inchoo_Test_Model</class>
      </test>
    </models>
    <resources>
      <test_setup>
        <setup>
          <module>Inchoo_Test</module>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </test_setup>
      <test_write>
        <connection>
          <use>core_write</use>
        </connection>
      </test_write>
      <test_read>
        <connection>
          <use>core_read</use>
        </connection>
      </test_read>
    </resources>
  </global>
  <crontab>
        <jobs>            
            <test>
                <schedule><cron_expr>10 00 * * *</cron_expr></schedule>
                <run><model>test/cron::hello</model></run>
            </test>
            <productremove>
                <schedule><cron_expr>50 23 * * *</cron_expr></schedule>
                <run><model>test/cron::bye</model></run>
            </productremove>
        </jobs>
  </crontab>
</config>

我每天晚上 7:00 都设置了 cron.sh。 cron.php 我在两种方法中都使用了日志。 hello 创建日志,而 bye 没有创建日志。我已经从 aoe_scheduler 运行了该 cron 手册,并且 productremove 在管理员中运行良好。有人可以告诉我跳过 productremove 的可能原因吗?

我对 cron 工作也有点困惑。如果我在每天晚上 7:00 设置 cron,那么它是在晚上 7:00 之前工作还是在同一天晚上 7:00 之后对所有调度程序工作。或者它将在晚上 7:00 之前和之后都有效

【问题讨论】:

    标签: magento model cron magento-1.9 scheduler


    【解决方案1】:

    原因是错误的 cron 配置。默认 magento cron.sh 使用每 5 分钟运行一次以赶上计划任务。 Aoe 调度器甚至建议每分钟运行一次。

    看看 Schedule->List View 看看你的 cronjobs 会发生什么。如果你每天只运行一次 cron.sh,你会看到很多任务被“跳过”

    【讨论】:

    • 我如何检查是否有任何计划被跳过?
    • 只需将状态过滤器应用于网格
    • 是的,但它显示的记录有限,所有旧历史记录已被删除,这是由于 magento cron 设置造成的吗?
    • 这由配置字段 History Cleanup Every 控制。您可以在 System->Configuration->System (Extended)->Cron 下找到它
    • 现在有10个,我应该设置多少。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-20
    • 1970-01-01
    • 2012-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多