How to Disable Cron Job in 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.