1

Sometimes indexing cron process went away and a similar thing happens for the consumers_runner and yotpo_yotpo_orders_sync cron job so I want to disable the consumers_runner and yotpo_yotpo_orders_sync cron job.

3 Answers 3

4

After reading the Magento Dev Documentation, I found a below solution:

Cron jobs do not have a disable feature as we have for observers. However, a Cron job can be disabled by using the following technique: schedule a time that contains a date that will never happen like 0 0 30 2 * which means At 00:00 on day-of-month 30 in February.

The detailed explanation is given here: https://devdocs.magento.com/guides/v2.4/config-guide/cron/custom-cron-ref.html#disable-cron-job

enter image description here

3

Disable Cron Job in Magento 2

To disable the cron job in Magento 2 you have to first create your module and rewrite the same cron job in your module’s crontab.xml file.

Let’s say I want to disable the cron job called notify_me which is defined in the Orange_Notify module. To disable this cron job create crontab.xml file under your custom module and change the schedule value to 0 0 30 2 *.

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="default">
    <job name="notify_me" instance="Orange\Notify\Model\Notify" method="execute">
        <schedule>0 0 30 2 *</schedule>
    </job>
</group>
</config>

By doing this we are telling Magento to run notify_me cron job at 00:00 on the 30th of February – at the date which will never happen. That means this cron job will never run.

2
  • 1
    How does Magento know that our schedule is the right one and not the one from the Orange_Notify module?
    – bfontaine
    Apr 27, 2022 at 7:52
  • 1
    @bfontaine Because your custom module has that module in sequence in the /etc/module.xml Sep 2, 2022 at 17:52
0

I think it can be better to create a patch.

In the composer.json file:

"extra": {
    "patches": {
        "yotpo/magento2-module-yotpo-reviews": {
            "Stop the Yotpo cron": "patches/yotpo-cron-stop.patch"
        }
    }
}

then create your patch file: <mage_dir>/patches/yotpo-cron-stop.patch using

<schedule>0 0 30 2 *</schedule>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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