1

I have been searching almost all day and i can't seem to find how i can change a cronjob/crontab its settings/schedule without using cache:reflush after changing the crontab.xml file.

This is so I can change a cronjob his schedule while the shop is running and i don't need to reflush the cache.

I think the cronjob's schedule get's saved in the cache but can't seem to find how not to do this...

so how can i do this?

EDIT: i can probably do this like this: How to set cronjob dynamic schedule from database in Magento 2

1 Answer 1

3

I did something simple using cron schedule expressions like: */5 * * * *

app/code/My/Module/etc/crontab.xml:

<?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="processSomething" instance="My\Module\Cron\Something" method="execute">
            <config_path>some_config/cron/schedule</config_path>
        </job>
    </group>
</config>

app/code/My/Module/etc/adminhtml/system.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
    <system>
        <section id="some_config" translate="label" type="text" sortOrder="300" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Hello!</label>
            <tab>mymodule</tab>
            <resource>My_Module::config</resource>
            <group id="cron" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Crons</label>
                <field id="schedule" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Cron schedule</label>
                    <comment>Fromat: * * * * *</comment>
                </field>
            </group>
        </section>
    </system>
</config>
1
  • Working on Magento 2.3.4 Commerce
    – Jiyaad.D
    Commented Jun 9, 2020 at 17:58

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.