greg-doak / cron-bundle
This bundle provides cron management.
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.1.3
- symfony/console: ^4.0
- symfony/orm-pack: ^1.0
- symfony/validator: ^4.0
This package is not auto-updated.
Last update: 2024-04-14 03:06:58 UTC
README
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