0

I would like to override some cron jobs of native crontab.xml

for example,

vendor/amzn/amazon-pay-and-login-magento-2-module/src/Payment/etc/crontab.xml

<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="get_amazon_capture_updates" instance="Amazon\Payment\Cron\GetAmazonCaptureUpdates" method="execute">
            <schedule>*/5 * * * *</schedule>
        </job>
        <job name="get_amazon_authorization_updates" instance="Amazon\Payment\Cron\GetAmazonAuthorizationUpdates" method="execute">
            <schedule>*/5 * * * *</schedule>
        </job>
        <job name="amazon_payments_process_queued_refunds" instance="Amazon\Payment\Cron\ProcessAmazonRefunds" method="execute">
            <schedule>*/5 * * * *</schedule>
        </job>
    </group>
</config>

I've created a very simple extension here

app/code/CustomVendor/Cron/

with file

app/code/CustomVendor/Cron/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="get_amazon_capture_updates" instance="Amazon\Payment\Cron\GetAmazonCaptureUpdates" method="execute">
            <schedule>0 1 * * 1</schedule>
        </job>
        <job name="get_amazon_authorization_updates" instance="Amazon\Payment\Cron\GetAmazonAuthorizationUpdates" method="execute">
            <schedule>0 1 * * 1</schedule>
        </job>
        <job name="amazon_payments_process_queued_refunds" instance="Amazon\Payment\Cron\ProcessAmazonRefunds" method="execute">
            <schedule>0 1 * * 1</schedule>
        </job>

        <job name="magento_newrelicreporting_cron" instance="Magento\NewRelicReporting\Model\Cron" method="runCron">
            <schedule>0 2 * * 1</schedule>
        </job>

    </group>
</config>

I ran the commands:

php bin/magento setup:upgrade

php bin/magento cron:run

php bin/magento setup:cron:run

Checked cron_schedule table. As I see it does not help.

enter image description here

What I did wrong. Please help.

3

Best way is to add this kind of record for core_config_data table :

path : crontab/default/jobs/get_amazon_capture_updates/schedule/cron_expr
value : 0 1 * * 1
scope: default
scope_id: 0

You have to do this for all cronjobs you want to update. I also suggest to install module https://github.com/Ethan3600/magento2-CronjobManager which allows you to change schedule for each cron job directly from the admin panel.

  • Thank you very much! It helps me. – PHPer Apr 25 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.