0

We are utilizing the Firebear module to import product and pricing data which run in the default cron group. The import takes quite a bit of time/resources so it was recommended to move the Firebear cron to its own group. The Firebear crontab.xml is currently setup like so:

vagrant/tmp/vendor/firebear/importexport/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="importexport_jobs_run_id" instance="Firebear\ImportExport\Cron\RunImportJobs" method="execute">
    <schedule>*/1 * * * *</schedule>
    </job>
    <job name="importexport_export_jobs_run_id" instance="Firebear\ImportExport\Cron\RunExportJobs" method="execute">
        <schedule>*/1 * * * *</schedule>
    </job>
    </group>
</config>

At a high level I will need to: 1 - create new cron group 2 - override Firebear crontab to run in new group

Any help on the process to accomplish this will be much appreciated.

0

Create a new module or add to an existing:

1 - New Cron Group

[module]/etc/cron_group.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
    <group id="new_cron_group_name">
        <schedule_generate_every>1</schedule_generate_every>
        <schedule_ahead_for>4</schedule_ahead_for>
        <schedule_lifetime>2</schedule_lifetime>
        <history_cleanup_every>10</history_cleanup_every>
        <history_success_lifetime>120</history_success_lifetime>
        <history_failure_lifetime>600</history_failure_lifetime>
        <use_separate_process>1</use_separate_process>
    </group>
</config>

2 - create new crontab.xml or add jobs to existing:

[module]/etc/crontab.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="new_cron_group_name">
        <job name="cron_job_name" instance="Magento\SomeModule\Cron\SomeJob" method="execute">
            <schedule>* * * * *</schedule>
        </job>
    </group>
</config>

3 - add the new cron group to .magento.app.yml

...
crons:
    ...
    newcrongroupname:
        spec: "* * * * *"
        cmd: "php bin/magento cron:run --group='new_cron_group_name'"

4 - remove the crontab.xml from the vendor module via deploy hooks in .app.magento.yml:

...
hooks:
    # We run build hooks before your application has been packaged.
    build: |
        set -e
        rm -f vendor/modulename/importexport/etc/crontab.xml
        php ./vendor/bin/ece-tools build:generate
        php ./vendor/bin/ece-tools build:transfer
...

My understanding is that #4 could also be done via a patch.

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.