acrnogor / crontab-manager-bundle
Crontab Manager bundle for SF 3.4.x and 4.x projects
v0.9.0
2020-12-11 14:58 UTC
Requires
- php: ^7.2
- q-alliance/crontab-manager: ^0.7
- symfony/console: ^4.2|^5.0
Requires (Dev)
- phpstan/phpstan: ^0.11
README
Installation
Composer install the package:
composer require acrnogor/crontab-manager-bundle
Symfony 3.4.*
Add configuration:
%PROJECT_DIR%/app/config/config.yml
, i.e.
acrnogor_crontab_manager: cron_jobs: - '*/8 * * * * /usr/bin/php /var/www/test/test.php > /dev/null 2>&1'
Include the bundle in your Kernel %PROJECT_DIR%/app/Kernel.php
:
<?php $bundles = [ // ... previous bundles new Acrnogor\CrontabManagerBundle\AcrnogorCrontabManagerBundle() ];
Add parameter to your parameters.yml
:
parameters: # ... crontab_user: www-data
and you're done. Skip to console.
Symfony ^4.0
Create a symfony config yaml file:
%PROJECT_DIR% /config/packages/acrnogor_crontab_manager.yml
, in example:
acrnogor_crontab_manager: cron_jobs: - '*/8 * * * * /usr/bin/php /var/www/test/test.php > /dev/null 2>&1' - '*/8 * * * * /usr/bin/php /var/www/sf4/bin/console debug:router > /dev/null 2>&1'
Add the bundle to the project - modify your config/bundles.php
and add the bundle like this:
<?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Acrnogor\CrontabManagerBundle\AcrnogorCrontabManagerBundle::class => ['all' => true] ];
Add parameter to your parameters.yml
:
parameters: # ... crontab_user: www-data
Console
Check if your command for updating crontab works, inside your project folder:
$ bin/console list acrnogor
Should show your new command. Run this to update your crontab with the given cron-jobs defined in config.
$ bin/console acrnogor:crontab:update