Skip to content

[Issue] Add --exclude-group to cron:run #36628

Closed
@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #34117: Add --exclude-group to cron:run


Description

https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-cron.html#config-cli-cron-group-run

When you decide to split a single cron group with the --group flag it means you need to do so for every group in your instance.

It's pretty common for third party modules to define their own groups whenever they like, so we have to keep up to date with the defined groups in the instance to keep adding these to our crontab when new groups are added.

One of my instances currently has 11 groups to manage, more will come in the future and its just something I need to mentally keep an eye on, a bit annoying.

In my case I only really want to run the crons like

* * * * * bin/magento cron:run --exclude-group index
* * * * * flock -n index.lock bin/magento cron:run --group index

This will give me better granular control over the indexer crons which can be useful when your store reaches hundreds of thousands of SKUs. Any other random cron groups would then still be able to run by default like in normal operation.

For future proofing I've made the --exclude-group flag stackable so you can define it multiple times like

* * * * * bin/magento cron:run --exclude-group index --exclude-group consumers

Manual testing scenarios (*)

  1. Run cron with no params, all groups run
  2. Run cron with --group, only that group runs
  3. Run cron with --group and that group also in --exclude-group, no groups run
  4. Run cron with --exclude-group, that group is excluded
  5. Run cron with multiple --exclude-group, all defined groups are excluded

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Metadata

Metadata

Assignees

Labels

Area: FrameworkComponent: CronIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: doneReported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions