How to Disable Cron Job in Magento 2

disable_cronjob_magento_2

As a Magento 2 developer many times you are in a situation where you have to disable cron job of some third-party modules. You have to disable that cron job because it is creating an issue or not running as per the cron schedule.

In Magento 2, cron jobs do not have a disable feature like observer and plugin. Then how to disable cron job in Magento 2? Well, in this post we will show you a very simple method to disable the cron job in Magento 2.

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.

Want to ask a question or leave a comment?

Leave a Comment

(0 Comments)

All the comments are goes into moderation before approval. Irrelevant comment with links directly goes to spam. Your email address will not be published.

Was this post helpful? Please support Us!

Follow us on twitter or Like us on facebook.

 


To Avoid Spam Downloads, We Want Your Email

We will send you download link right
away. Please submit form below.
SEND ME DOWNLOAD LINK
Close

Increase Your
Magento 2
Knowledge

Get Weekly Tutorial
to your Inbox
Subscribe Me
close-link
Subscribe Here