1

I have a etc/cron_groups.xml set as follows:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
    <group id="cron_group_name">
        <schedule_generate_every>180</schedule_generate_every>
        <schedule_ahead_for>10</schedule_ahead_for>
        <schedule_lifetime>20</schedule_lifetime>
        <history_cleanup_every>10</history_cleanup_every>
        <history_success_lifetime>1440</history_success_lifetime>
        <history_failure_lifetime>43200</history_failure_lifetime>
        <use_separate_process>1</use_separate_process>
    </group>
</config>

I noticed that if I follow the default settings on http://devdocs.magento.com/guides/v2.1/config-guide/cron/custom-cron-ref.html, the CRON job can run properly. As I want to run CRON job every 3 hours, I set <schedule_generate_every> to 180, and adjusted other attributes as above. Have I done sth wrong on the settings?

  • run php bin/magento cron:run command from your terminal and check cron_schedule table in database. Try to run the command twice and check does your job entry in database – Priyank Jun 30 '17 at 4:40
  • follow this answer, magento.stackexchange.com/questions/149276/… its throw any error in your cron job code. – Rajkumar .E Jun 30 '17 at 5:12
  • @userpk No entry on databases. – PY Yick Jun 30 '17 at 5:16
  • @Rajkumar.E It shows Done – PY Yick Jun 30 '17 at 5:22
  • check your cron_schedule table , status of your cron jobs – Rajkumar .E Jun 30 '17 at 5:27
0

After studying the codes in the core, I attempt to modify the value of <schedule_ahead_for> and <schedule_lifetime>. I changed back to the default value on the reference suggested. OK, it runs again.

After that, I changed the value of <schedule_ahead_for> and <schedule_lifetime>. I found out if the value of <schedule_ahead_for> is larger than <schedule_lifetime>, then CRON job may not write into the cron_schedule table. That caused the CRON job didn't run on schedule.

So, my final decision is: it's OK to follow the default value of etc/cron_groups.xml. As long as the schedule is not near the schedule time, the system will not add a record on cron_schedule table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.