定制 mhary/cron-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mhary/cron-bundle

Composer 安装命令:

composer require mhary/cron-bundle

包简介

With the CronBundle you can configure cron jobs in configuration files

README 文档

README

Symfony2 / Symfony 3 Bundle for setting up cron jobs via configuration.

Fork of unsupported skck/SbkCronBundle

PHP 7.0+ required

Installation

Prerequisites

This bundle requires Symfony 2.1+

Now install it with this command:

composer require mhary/cron-bundle

Enable the bundle

You need to add the bundle in app/AppKernel.php

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Mhary\Bundle\CronBundle\MharyCronBundle(),
    );
}

Import Services

The CronBundle depends on certain services, so you need to import the service configuration in app/config/config.yml

imports:
    # ...
    - { resource: @MharyCronBundle/Resources/config/services.yml }

Now you should be able to use the Cron Manager.

Usage

Configuring Tasks

Tasks can be configured in app/config/config(_prod).yml.

mhary_cron:
  tasks:
    clearcache:
      command: "cache:clear --env=prod"
      expression: "0 0 * * *"
    listoutput:
      bin: "ls"
      script: ""
      command: "-l > /var/log/listoutput.log"
      expression: "@daily"
      

Each entry in mhary_cron.tasks represents a task.

command

The command to execute. By default the cron manager will prepend php %kernel.root_dir%/console before the command name, so configuring console commands is easy. You can run every command you want with this bundle, read on how to do so.

expression

The cron expression, any valid expression that you would enter in a cron table.

bin

The binary which will execute the command (php by default, you could enter '' to omit the bin in the execution command)

script

The script that will be called (%kernel.root_dir%/console by default).

Runnign the master cron job

Even if you can configure all cron jobs with this bundle, you need to add one line to the crontab manually, the cron:run command.

* * * * * php /var/www/app/console cron:run

This will execute the cron manager every minute.

The manager will check which tasks need to be executed and will create background processes for every due task.

License

The MIT License. For the full text of license, please, see LICENSE

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固