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

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

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.

| improve this answer | |

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.