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

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

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

skrip42/cron-bundle

Composer 安装命令:

composer require skrip42/cron-bundle

包简介

Symfony Cron-bundle

README 文档

README

task scheduler for symfony witch extended syntax similar to cron.

install:

  • run composer require skrip42/cron-bundle
  • create database php ./bin/console make:migration and php ./bin/console doctrine:migration:migrate
  • add * * * * * ./bin/console cron:run in you crontab

schedule-task syntax:

task pattern is {minute}_{house}_{day}_{weekday}_{month}_{year}

operant description example
* run everytime *_*_*_*_*_* - will be executed every minute
n,m run in n and m 5,10_*_*_*_*_* - will be executed in 5 and 10 minute
!n run everytime except n *_*_*_!1_*_* - will be executed everytime except Monday
n+m run in n+m 5+10_*_*_*_*_* - will be executed in 15 minutes
n-m run in n-m 15-10_*_*_*_*_* - will be execute in 5 minutes
-n run in m-n where m is max value of range (-5 in minute part equal 55 minute) *_*_- 1_*_*_* - will be executed on the last day of the month
n/m run when n aliquot m (*/5 in minute part - run every 5 minute) */5_*_*_*_*_* - will be executed every 5 minutes
n:m run in range from n to m 5:10_*_*_*_*_* - will be executed in 5,6,7,8,9 and 10 minutes
(n) group of operators !(5,10,15)_*_*_*_*_* - will be executed every minute except 5,10 and 15 minute

Operators can be combined, for example: 0_0_*/2-1_*_*_* - will be executed at midnight on odd days.

available command:

  • cron:add - interactiv adding cron task
  • cron:closest - show list of closest task
  • cron:list - show list of cron task
  • cron:list --all - show list of all activity status cron task
  • cron:optimize - disable outdated cron tasks
  • cron:run - run actual task
  • cron:update $id - update cron task
  • cron:toggle $id - toggle cron task activity

usage:

....... //you namespace declaration

use Skrip42\Bundle\CronBundle\Services\Cron;
use Skrip42\Bundle\CronBundle\Component\Pattern;

....... //you class declaration

protected $cron; //instance of Cron service

public function __construct(Cron $cron) {
    $this->cron = $cron
}

........ //in you method
$this->cron->getActualOnCurrentTime(); // return array of actual Schedule entity
$this->cron->optimize(); // disable outdated cron tasks
$this->cron->closestList($count); // return $count closest task in format: [$id, $command, $c]
$this->cron->getList($all); // return all schedule task? if $all = true includes disabled task
$this->cron->addSchedule($patternString, $commandString); // create new schedule task
$this->cron->toggleSchedule($id); // toggle schedule task activity
$this->cron->updateSchedule($id, $patternString, $commandString); // update schedule task

$pattern = new Pattern($patternString); // get pattern object
$pattern->test(new DateTime('NOW')); // test pattern for match date
$pattern->getClosest($count); //return $count closest date that match pattern

$schedule = reset($this->cron->getList()); // schedule is standart doctrine entity
$schedule->getId(); //return id
$schedule->getCommand(); // return command string
$schedule->setCommand($commandString); // set command string to schedule
$schedule->getPattern(); // return pattern string
$schedule->setPattern($patternString); // set pattern string to schedule
$schedule->toggleActive(); // toggle schedule activity

$this->container->get('doctrine')->getManager()->flush(); // to save change
........

skrip42/cron-bundle 适用场景与选型建议

skrip42/cron-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 450 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-11