blackbird/selective-cron 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blackbird/selective-cron

Composer 安装命令:

composer require blackbird/selective-cron

包简介

README 文档

README

Latest Stable Version License: MIT

The Selective Cron module allows you to selectively execute only specific cron jobs. This is useful for debugging, testing, or when you want to run only certain cron jobs without affecting others.

Features

  • Configuration in the admin panel to select which cron jobs to execute
  • Custom command line interface similar to cron:run to execute only selected cron jobs
  • Dedicated database table to track scheduled cron jobs
  • Automatic execution of selected cron jobs at their scheduled times
  • Continuous scheduling of new job instances according to their own periodicity
  • Dedicated logging for selective cron execution

Requirements

  • PHP >= 8.1
  • Magento >= 2.4.4

Setup

Get the package

Zip Package:

Unzip the package in app/code/Blackbird/SelectiveCron, from the root of your Magento instance.

Composer Package:

composer require blackbird/selective-cron

Install the module

Go to your Magento root, then run the following Magento command:

php bin/magento setup:upgrade

If you are in production mode, do not forget to recompile and redeploy the static resources, or to use the --keep-generated option.

Configuration

  1. Go to Stores > Configuration > Advanced > System > Cron (Selective Cron)
  2. Select the cron jobs you want to execute
  3. Save the configuration

When you save the configuration, the module will automatically:

  • Clear the existing selective cron schedule
  • Create new schedule entries for the selected cron jobs

Usage

The module provides multiple ways to execute and manage the selected cron jobs:

Automatic Execution

The module includes two cron jobs for automatic execution:

  1. Execution Cron Job: Runs every minute to check for and execute any scheduled selective cron jobs that are due to run. This ensures that your selected cron jobs run at their scheduled times without manual intervention.

  2. Scheduling Cron Job: Runs every 15 minutes to check for jobs that need new instances and adds them to the schedule table. This ensures that new instances of selected cron jobs are continuously added according to their own periodicity.

The scheduling mechanism:

  • Calculates the next run time based on each job's cron expression
  • Ensures that there's always at least one pending instance for each selected job
  • Schedules new instances ahead of time (up to 1 hour in advance)
  • Respects each job's individual schedule (e.g., hourly, daily, weekly)

Manual Execution

To manually run the selected cron jobs, use the following command:

bin/magento cron:run:selective

This command will:

  1. Check if there are any pending jobs in the selective cron schedule
  2. Execute any jobs that are due to run
  3. Update the job status in the schedule table

System Crontab Integration

The module provides commands to install and remove the selective cron job from the system crontab:

Installing in System Crontab

To install the selective cron job in the system crontab, use the following command:

bin/magento cron:install:selective

This command will:

  1. Check if the selective cron functionality is enabled in the configuration
  2. Add a crontab entry to run bin/magento cron:run:selective every minute
  3. The entry will only be added if the selective cron functionality is enabled

If crontab entries already exist, you can use the --force option to overwrite them:

bin/magento cron:install:selective --force

Removing from System Crontab

To remove the selective cron job from the system crontab, use the following command:

bin/magento cron:remove:selective

This command will:

  1. Remove only the selective cron entries from the system crontab
  2. Leave other Magento cron entries intact

Database

The module creates a selective_cron_schedule table that mirrors Magento's cron_schedule table. This table stores information about scheduled selective cron jobs, including:

  • Job code
  • Status (pending, running, success, error, missed)
  • Scheduled time
  • Execution time
  • Completion time
  • Error messages (if any)

Logging

Logs are stored in var/log/selective_cron.log

Support

Contact

For further information, contact us:

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.

That's all folks!

blackbird/selective-cron 适用场景与选型建议

blackbird/selective-cron 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 blackbird/selective-cron 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 blackbird/selective-cron 我们能提供哪些服务?
定制开发 / 二次开发

基于 blackbird/selective-cron 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-21