babymarkt/cron-bundle
Composer 安装命令:
composer require babymarkt/cron-bundle
包简介
A simple Symfony cron bundle to edit the system crontab.
README 文档
README
A small bundle to manage cron entries in system crontab.
Installation
You need to require this library through composer:
composer require babymarkt/cron-bundle
If you are using Symfony Flex, the following will happen automatically. Otherwise,
you have to enable the bundle on the bundles.php manually:
// config/bundles.php return [ // ... Babymarkt\Symfony\CronBundle\BabymarktCronBundle::class => ['all' => true], ];
Configuration
Let's start with a minimal setup to run a job every minute:
babymarkt_cron: cronjobs: my_job: 'my:symfony:command'
After syncing the cronjobs with the command bin/console babymarkt-cron:sync --env=prod,
following entry are created in the crontab:
###> /your/project-dir:prod ###
# job 'my_job' (no description)
* * * * * cd /your/project-dir; php bin/console --env=prod my:symfony:command 2>&1 1>>/dev/null
###< /your/project-dir:prod ###
To learn more about CRON see CRON expression on Wikipedia.
Examples
A job running every day at 3:30 AM
babymarkt_cron: cronjobs: my_job: command: 'my:symfony:command' minutes: 30 hours: 3
A job running every Tuesday every 10 minutes between 1:00 and 4:00 AM
babymarkt_cron: cronjobs: my_job: command: 'my:symfony:command' minutes: '*/10' # or '0,10,20,30,40,50' hours: '1-4' weekdays: 3 # Tuesday (SUN-SAT: 0-6)
Full configuration reference
babymarkt_cron: options: # This ID is used to identify the job block in the crontab. If not defined, # it is automatically generated from the project directory and the environment. id: ~ # The script to run the commands. script: 'bin/console' # The working directory. Defaults to %kernel.project_dir%. working_dir: ~ # Specifies globally where the output should be written to. output: file: '/dev/null' append: true # Crontab options crontab: # Crontab executable. bin: 'crontab' # Path to store the temporary crontab content. Defaults to the system temp dir. tmpPath: ~ # The user to execute the crontab. user: ~ # Defines whether sudo is used or not. sudo: false cronjobs: # The name of the job definition your-first-job-name: # Definition of the execution time # See https://en.wikipedia.org/wiki/Cron#CRON_expression minutes: * hours: * days: * months: * weekdays: * # The Symfony command to execute. command: ~ # required # If TRUE, the command isn't executed. disabled: false # Overwrites the global output settings. output: file: ~ append: ~ # Command arguments and options. arguments: - '<<your-first-argument>>' - '<<your-second-argument>>' #...
Commands
babymarkt-cron:drop
Drops all the whole cronjobs block from crontab not considering the configured cronjobs.
babymarkt-cron:dump
Generates the cron entries which may be installed to crontab and shows it on console.
babymarkt-cron:report
Show some reports about the execution of the configured cronjobs. This features required the DoctrineBundle.
babymarkt-cron:sync
Syncs the configured cronjobs with the crontab. Only the related cron block will be affected.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Baby-Markt/cron-bundle.
License
The bundle is available as open source under the terms of the MIT License.
babymarkt/cron-bundle 适用场景与选型建议
babymarkt/cron-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 819 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 09 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「cron」 「crontab」 「crond」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 babymarkt/cron-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 babymarkt/cron-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 babymarkt/cron-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle to monitor and execute commands
The bundle for easy using json-rpc api on your project
Scheduling extension for Yii2 framework
Monitoring for scheduled jobs
Bundle Symfony DaplosBundle
Temporal frequency library
统计信息
- 总下载量: 819
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-27