# magemojo/m2-ce-cron

> Replacement package for Magento 2 Cron Functionality

`composer require magemojo/m2-ce-cron`

Canonical URL: https://packagento.com/magemojo/m2-ce-cron

## At a glance

- **Vendor**: magemojo (https://packagento.com/magemojo.md)
- **Latest version**: 1.4.3-stable — released 2022-12-13
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/magemojo/m2-ce-cron and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require magemojo/m2-ce-cron:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Replacement package for Magento 2 Cron Functionality

## README

[![MageMojo](https://magetalk.com/wp-content/uploads/2017/11/q7xJZaM5TImMN7mUIb0c.png)](https://magemojo.com/)

## Cron
##### This module for Magento 2 overrides base magento cron functionality, fixes known bugs, and provides a cron service model to control cron process execution. 

![Version 1.4.2](https://img.shields.io/badge/Version-1.4.3-green.svg)

NOTICE: Version 1.3x is only supported for Magento 2.3 and above. Older Magento 2 version use module version 1.2

The default cron can overlap and fill the cron_schedule table, which can cause exponentially more jobs to run on each cron interval, until finally the crons run continuously and never complete.  The high number of cron jobs can also crash servers hosting Magento 2. 

This module replaces the cron management with a service that accepts jobs. As jobs are scheduled, they are picked up by this service for execution.  If a job is already running and another is picked up with the same job code, the new one is marked as missed.  Duplicate jobs are prevented from running, reducing server overhead.

Think of the default cron as a factory that suddenly appears and runs any number of tasks. If those tasks do not complete by the next cron interval, they keep processing but another factory spontaneously appears and run another set of jobs which can overlap with the original factory.  

The module removes the possibility of overlapping jobs by having a single source service that processes jobs in proper order without duplication. There is one factory working all the time to get your jobs done. 

In addition to the service model many other enhancements have been made.  For example a re-write of left join on update statement that forced a full table scan on cron_schedule for history.  Statement would lock because it's reading from same table it was trying to update.

In version 1.1 Cron Reporting was added to the admin to show job code statistics and list cron run errors.

In version 1.2.5 Cron execution will run if in maintenance mode with exempt IPs, allowing for full internal verification including necessary crons.

In version 1.3 fixes are implemented for the consumers_runner cron job. This job code is a throwback from magento 1 and is more frequently used in Magento 2.3. It runs under its own scheduler which can execute many child jobs and bomb the system. In this version of the module this parent job is intercepted and written as individual jobs in the cron_schedule table and then run in a sane manner from there. These consumer jobs can also go into infinite loops, so a timeout is imposed on them by default of 30 seconds. This setting can be adjusted in the admin.

In version 1.3.7 the consumers governor was added to terminate idle consumers jobs. Bugs in these jobs otherwise prevent these jobs from completing.

In version 1.4.2 Support for clusters was added and fix for honoring disabled consumers jobs

In version 1.4.3 Support for PHP 8.1

### Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md).

### Benefits

* Speeds up execution of cron.

* Stops db locking.

* Prevents cron history records from exploding.

* Stops cron processes from overrunning each other.

* Stops the cron from running while system is under configurable load conditions.

* Sets the max number of simultaneous cron processes.

* Sets the amount of history. 

### Admin Options

**Cron Enabled** - Turn the cron on/off.

**Cluster Support** - REQUIRED for Magento Commerce Cloud or any scaled/clustered environment. If more than one app server could potentially execute the `cron:run` command, 
enable this. This will allow the service to gracefully switch between "leader" servers as required.

**Maximum Cron Processes** - The number of cron threads running in parallel.  This option is the sum of all defined jobs.  Example: If you have 5 jobs set to run at midnight, Maximum Cron Processes set to 1, only 1 job will execute sequentially until all 5 are completed. Default 3.

**PHP Binary Name / Path** - The name of your php binary you run from the shell.  Usually php or php70.  You can optionally include the full path to the binary. Default php. You can also add inline options here such as php -dmemory_limit=8096M If you want to have a custom ini value.

**Max Load Average** - Defined by the php function sys.getloadavg() / number of cpu cores. The function sys.getloadavg() is reported 1.0 for each core in use, just like the load average reported in top.  The number of cpu cores is pulled from /proc/cpuinfo and load average is divided by this number. Example: If you have 8 cores and you're using 6 then this is returned as 0.75. If your Max Load Average is 0.76 your crons will not run. Your load average falls to 0.74.  Your crons will run.  Any cron that was scheduled to run but didn't will be run.  If the same cron was missed multiple times, the most recent job will run, and the rest will be marked as missed. Default is 0.75 (75% of your available cpu).

**History Retention** - The number of days history to keep in the cron_schedule table. Default 1 (1 day).

**Consumers Job Timeout** - The number of seconds to allow a consumer job to run. These jobs can infinitely run under some conditions.

**Exporters Job Timeout** - The number of seconds to allow the exportProcessor job to run. Default 3600 seconds.

**Consumers Govenor:** - Many bugs in consumers processes cause them to run infinitely. The consumers governor will detect these states and terminate the processes.

### Composer Install

- Run these commands in your terminal:

- For Magento Versions 2.3 and up
```bash
composer require magemojo/m2-ce-cron
```
- Otherwise
```bash
composer require magemojo/m2-ce-cron:1.2.9
```

- Then run the following
```bash
php bin/magento module:enable MageMojo_Cron
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
```
- Log into your admin and set your options under System -> Cron Settings

_(README truncated for .md surface. Full README on https://packagento.com/magemojo/m2-ce-cron.)_

## Recent Versions

| Version | Released |
|---|---|
| 1.4.3-stable | 2022-12-13 |
| 1.4.2-stable | 2022-02-23 |
| 1.3.8-stable | 2021-03-17 |
| 1.3.7-stable | 2020-11-16 |
| 1.3.5 | 2020-06-25 |
| 1.3.4 | 2020-06-18 |
| 1.3.3-stable | 2020-06-12 |
| 1.3.2-stable | 2020-04-22 |
| 1.3.1-stable | 2020-02-07 |
| 1.3.0-stable | 2020-01-07 |

Showing 10 of 20 versions. Full release history on https://packagento.com/magemojo/m2-ce-cron.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| php | >=7.0.0 |

### Suggest

| Package | Constraint |
|---|---|
| magento/framework | * |
| magento/module-config | * |
| magento/module-cron | * |
| magento/module-store | * |

## Quality

Latest release (1.4.3-stable) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | 1 | 1 |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 940 | 38 errors, 902 warnings (ruleset: Magento2) — 726 auto-fixable with phpcbf |
| PHPMD | Warning | 19 | 19 rule violations (CyclomaticComplexity:3, UnusedFormalParameter:3, UnusedPrivateField:2, NPathComplexity:2, TooManyFields:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Pass | 0 |  |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 23 | 23 | – | – |
| 2.4.8 | – | 23 | 24 | – |
| 2.4.9 | – | – | 26 | 26 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["magemojo/m2-ce-cron"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

magemojo is a Magento 2 vendor on Packagento. See https://packagento.com/magemojo.md for their full catalogue.

