Multiple cron jobs scheduled for the same time period

This article provides a patch for a known Adobe Commerce 2.2.2 issue related to having multiple cron jobs scheduled to run at the same time after the time variables for certain tasks were edited in the Commerce Admin.

Issue

When cron is configured to run every minute, if you edit time variables for three scheduled tasks in Admin, the cron_schedule database table shows groups of multiple tasks scheduled to run at the same time.

Steps to reproduce:

  1. In Commerce Admin, navigate to Stores > Settings > Configuration > ADVANCED > System > Cron (Scheduled Tasks) > Cron configuration options for group: default.

  2. Configure the following options:

    • History Cleanup Every: clear the Use system checkbox, and set to 1440.
    • Success History Lifetime: clear the Use system checkbox, and set to 1440.
    • Failure History Lifetime: clear the Use system checkbox, and set to 1440.
  3. Click Save Config.

  4. In SSH, run the crontab -e command.

  5. Set cron to run every minute.

  6. Open three terminal tabs/windows.

  7. Go to the Adobe Commerce root/base/project directory in each terminal window.

  8. Run the following command in each tab/window:

    code language-bash
    bin/magento cache:flush && bin/magento cron:run && bin/magento cache:flush && bin/magento cron:run
    
  9. Go to MySQL and run the following query:

    code language-sql
    SELECT job_code, scheduled_at, count as count FROM cron_schedule GROUP BY job_code, scheduled_at HAVING count > 1 ORDER BY scheduled_at;
    
  10. See groups of tasks scheduled to run at the same time.

Expected result: One cron job_code should be scheduled for the certain time period.

Actual result: There are multiple cron jobs scheduled for the same time period.

Solution

For Adobe Commerce on cloud infrastructure merchants, updating the ECE-tools will solve the issue.

Adobe Commerce on-premises merchants should apply one of the attached patches to solve the issue.

Patches

The patches are attached to this article. To download, scroll down to the end of the article and click the file name, or click one the following link:

Compatible Adobe Commerce versions

The patches were created for particular version noted in the patch file name. For example, MDVA-11304_EE_2.2.4_COMPOSER_v1.patch was created for Adobe Commerce 2.2.4 and is the best patch to be used for this version.

The patches are also compatible with the following versions:

  • For Adobe Commerce on-premises 2.1.0-2.1.4: Download MDVA-11304_EE_2.1.4_COMPOSER_v1.patch The patch is also compatible (but might not solve the issue) with the following Adobe Commerce versions and editions:

    • Adobe Commerce on cloud infrastructure 2.1.0-2.1.4
  • For Adobe Commerce on-premises 2.1.5-2.1.12: Download MDVA-11304_EE_2.1.5_COMPOSER_v1.patch The patch is also compatible (but might not solve the issue) with the following Adobe Commerce versions and editions:

    • Adobe Commerce on cloud infrastructure 2.1.5-2.1.12
  • For Adobe Commerce on cloud infrastructure 2.1.13: Download MDVA-11304_EE_2.1.13_COMPOSER_v1.patch

  • For Adobe Commerce on-premises 2.1.14-2.1.17: Download MDVA-11304_EE_2.1.14_COMPOSER_v1.patch The patch is also compatible (but might not solve the issue) with the following Adobe Commerce versions and editions:

    • Adobe Commerce on-premises 2.1.18
    • Adobe Commerce on cloud infrastructure 2.1.14-2.1.18
  • For Adobe Commerce on-premises 2.2.0-2.2.1: Download MDVA-11304_EE_2.2.0_COMPOSER_v1.patch The patch is also compatible (but might not solve the issue) with the following Adobe Commerce versions and editions:

    • Adobe Commerce on cloud infrastructure 2.2.0-2.2.1
  • For Adobe Commerce on-premises 2.2.0-2.2.3: Download MDVA-11304_EE_2.2.2_COMPOSER_v1.patch The patch is also compatible (but might not solve the issue) with the following Adobe Commerce versions and editions:

    • Adobe Commerce on cloud infrastructure 2.2.0-2.2.3
  • For Adobe Commerce on-premises 2.2.4: Download MDVA-11304_EE_2.2.4_COMPOSER_v1.patch The patch is also compatible (but might not solve the issue) with the following Adobe Commerce versions and editions:

    • Adobe Commerce on cloud infrastructure 2.2.4

How to apply the patch

See How to apply a composer patch provided by Adobe Commerce in our support knowledge base, for instructions.

Attached Files

recommendation-more-help
8bd06ef0-b3d5-4137-b74e-d7b00485808a