1

I have a crojob in my custom module and want to disable it temporarily

The xml files for the cronjob are:

app/code/Vendor/Module/etc/cron_groups.xml
app/code/Vendor/Module/etc/crontab.xml

I have tried to comment out the code from cron scheduling

<?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="my_cron_id">

        <!--<job name="my_cron_name" instance="Vendor\Module\Cron\MyCron" method="execute">
            <schedule>0 3 * * *</schedule>
        </job>-->

    </group>
</config>

But after this, my module went stopped working with no error.

I just simply wants to disable it temporarily how can I do this?

3 Answers 3

2

I think if you have only one cronjob in your crontab.xml file and you want to remove it, you should rename your file to be _crontab.xml and clear the cache.

2
  • I renamed both xml files with _. I hope I would find proper solution for this, but for now it resolved the issue. Thanks for helping :) Apr 17, 2019 at 5:46
  • 1
    i had the similar issue with events.xml file. I had only one event and i tried to comment that, which causes magento to showing me error as when magento is reading xml, it expects atleast one element or else it stops working.
    – Yash Shah
    Apr 17, 2019 at 5:59
0

You can run the cron command cron:remove.
Reference

1
  • Thanks for the answer, but it will remove all the cronjobs of magento, not just my custom cronjob Apr 17, 2019 at 5:04
0

You could try php bin/magento cron:remove. Check https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-cron.html#config-cli-cron-group-run for more details

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.