Skip to content

GregDoak/CronBundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CronBundle

This bundle provides cron management utilities for your Symfony Project

Installation

Add greg-doak/cron-bundle to your composer.json

$ composer require greg-doak/cron-bundle

Register the bundle in config/bundles.php

return [
    // ...
    GregDoak\CronBundle\GregDoakCronBundle::class => ['all' => true],
];

Create the database tables

$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate

Or

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

Create your first task

$ php bin/console cron:create

Configuration

Add the scheduler to your cron

*/5 * * * * php /root/to/your/application/bin/console cron:run:scheduled

Or alternatively to run the scheduler on page request Configure services.yaml

parameters:
    // ...
    gregdoak.cron.run_on_request: true

This can have performance issues so is recommended to run on Development environments only

Usage

Run a single task, you will be prompted for which task to run

$ php bin/console cron:run:single

Kill a running task, you will be prompted for the running task

$ php bin/console cron:kill

Update a task

$ php bin/console cron:update

Notes

There are 3 database tables created:

cron_jobs - A record is created whenever the scheduler or single task is run and ensures tasks cannot be ran simultaneously. It also records a start and end time to measure performance of the entire job

cron_job_tasks - Each record consists of a single task, running tasks will be reserved by recording a cron_job_id

cron_job_logs - A log is created for each task to record the output, exit code, start and end times

Releases

No releases published

Packages

No packages published

Languages