kempfe/cron-manager

Cron Manager for Symfony3

1.0.7 2017-08-01 13:34 UTC

This package is not auto-updated.

Last update: 2024-05-20 06:12:12 UTC


README

Cron Manager for Symfony 3 Create managable cron tasks for your symfony project

Installing

1. Add the dependency to your project:

composer require kempfe/cron-manager

2. Add package to your AppKernel.php

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new CronManager\CronManager()
        ];
        ...

3. Update your database

php bin/console doctrine:schema:update --force

####This Package is based on mtdowling/cron-expression Cron Expression Parser

Creating a Cron Task

  1. Create a Symfony Command like described here http://symfony.com/doc/master/components/console.html

  2. Create a new database entry into cm_cron with fields:

    leave the rest of the fields blank

Cron Manager Execution

php bin/console cm:run --interval=600 --processCheck=1

####Options

  • --interval: Your Linux Cron execution interval - default execution interval is 600 seconds
  • --processCheck: When enabled it checks process id to avoid overlapping executions