troopers/cron-bundle

此包已废弃,不再维护。未建议替代包。
此包最新版本(0.1-beta1)的许可信息不可用。

用于以cron方式运行命令的Symfony扩展包

安装: 34

依赖者: 0

建议者: 0

安全: 0

星标: 6

关注者: 10

分支: 0

开放问题: 1

类型:symfony-bundle

0.1-beta1 2018-02-02 00:03 UTC

This package is not auto-updated.

Last update: 2021-12-06 23:20:42 UTC


README

Troopers Twitter Follow

CronBundle

概要

此扩展包用于通过yaml配置文件定义symfony命令作为cron。

安装

运行composer require robinstraub/cron-bundle

如果您不使用flex,请在AppKernel中注册此扩展包

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Troopers\CronBundle\CronBundle(),
            ...
        );

        return $bundles

配置

config.yml中添加您的配置。以下示例显示了如何自定义您的命令

troopers_cron:
    reporting:
        api:
            url: 'http://monitoring_api.local/api/cron'
            api_key: 'myapikey'
            format: form
    tasks:
        - command: 'help'
          schedule: '* * * * *'
          arguments:
            command_name: 'cache:clear'
        - command: 'cache:clear'
          schedule: '@daily'
          arguments: 
            --env: 'prod'
            --no-debug: null

报告

使用reporting键,您可以使用报告工具来跟踪任务执行。目前唯一可用的工具是api

API

  • url:API URL(基本URI和API路由)
  • api_key:用于身份验证的可选API密钥
  • format:用于数据的数据格式。目前仅实现form。默认值为form

任务

要执行的命令列表。

  • command:要执行的命令
  • schedule:cron计划
  • arguments:命令的参数列表

设置cron任务

将以下行添加到您的crontab中

* * * * * /path/to/symfony/install/app/console cron:run 1>> /dev/null 2>&1