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. Please do not spam. Your email address will not be published. Required fields are marked *

Enjoy this post? Please support Us!

Follow us on twitter for daily new updates..

 

Want to become
a Magento 2 Expert?

If Yes! Then Subscribe to our newsletter and get weekly article to you email id.
Subscribe Here
SUBSCRIBE NOW
close-link

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