Composer install the package:
composer require acrnogor/crontab-manager-bundle
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.
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
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