1

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.

3 Answers 3

1

I can't comment on existing posts because i'm missing reputation or something like that, so i'm going to do it this way for the sake of clarity.

Aren't the last 2 steps, in guerinteed_mike's answer, just for Magento Cloud? To my knowledge, they use the .magento.app.yml file for configuring the server environment on their own hosting platform.

4
  • Yes, this was used on a Magento Clooud instance Commented Feb 9, 2020 at 15:40
  • Wouldn't it be better to update your answer then? Other users not having the cloud edition might be confused by the last steps. Or is there anything i missed within this topic that is restricted to cloud only?
    – Kozie
    Commented Feb 11, 2020 at 10:10
  • Updated. Note - sometimes some aspects are not known when learning something new. Commented Feb 11, 2020 at 17:26
  • I didn't mean to be harsh or anything but just noticed it and thought it could be clarified. Thanks for updating! :)
    – Kozie
    Commented Feb 13, 2020 at 9:10
1

Create the new Cron Group and Cronjob as explained by guerinteed_mike.

Now to disable the crojob from the default group you can override the same in your custom file. This will avoid executing the default cron.

<group id="default">
    <job name="importexport_export_jobs_run_id" instance="Firebear\ImportExport\Cron\RunExportJobs" method="execute">
        <schedule>0 0 30 2 *</schedule>
    </job>
</group>
0

This is the solution I used for a Magento 2.2 commerce instance hosted on Adobe Cloud.

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 and acknowledge you have read our privacy policy.

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