1

I have a scheduled cron job that is set to run every day at 12:00am. The job runs correctly as per scheduled time, but the same job is again created at 12.01am. So technically the cron is run twice. The job is scheduled to send out emails every day, but each email is sent out twice and it's not a great experience. What should I do to stop the second job from getting created?

  • could you show us your crontab.xml and cron_groups.xml for your cron job? – Edwin Widhiyanto Feb 9 '18 at 8:00
  • Below is the crontab.xml i have not created a seperate cron_groups.xml . <?xml version="1.0"?> <config xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> <group id="default"> <job name="daily_report" instance="path" method="execute"> <schedule>00 14 * * *</schedule> </job> </group> </config> – Vaish Feb 9 '18 at 11:50
0

You could try to change your custom cron job group like in code below.

cron_groups.xml :

<group id="default">
    <schedule_generate_every>15</schedule_generate_every>
    <schedule_ahead_for>20</schedule_ahead_for>
    <schedule_lifetime>15</schedule_lifetime>
    <history_cleanup_every>10</history_cleanup_every>
    <history_success_lifetime>60</history_success_lifetime>
    <history_failure_lifetime>600</history_failure_lifetime>
    <use_separate_process>0</use_separate_process>
</group>

Or if you just got crontab.xml, you should set the schedule like code below.

crontab.xml :

<schedule> 1439 * * *</schedule>

The time setting are in minute, not what hour the cron will start, then if you set the schedule 00 it will create double cron each it start.

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.