troopers/cron-bundle

There is no license information available for the latest version (0.1-beta1) of this package.

Symfony bundle for running commands as cron

Installs: 32

Dependents: 0

Suggesters: 0

Stars: 6

Watchers: 10

Forks: 0

Open Issues: 1

Type:symfony-bundle

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

README

Troopers Twitter Follow

CronBundle

Synopsis

This bundle is used to define symfony commands as cron using a yaml configuration file.

Install

run composer require robinstraub/cron-bundle

If you are not using flex, registrer the bundle in AppKernel

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

        return $bundles

Configuration

Add your configuration in config.yml. See the following example on for how to customize your commands

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

The reporting key let you use a reporting tool in order to keep track of tasks execution. The only tool available for now is the api.

api

  • url: api url (base uri and api route)
  • api_key: optional api_key used for authentication
  • format: format used for the data. Only form is implemented. Default value is form

tasks

The list of commands to execute.

  • command: command to execute
  • schedule: cron schedule
  • arguments: list of the command's arguments

Mise en place des cron

Add the following line to your crontab:

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