babymarkt/cron-bundle 问题修复 & 功能扩展

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

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

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.

Build 2.x codecov Packagist Version License PHP from Packagist PHP from Packagist

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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-27