This bundle is used to define symfony commands as cron using a yaml configuration file.
run composer require robinstraub/cron-bundle
If you are not using flex, registrer the bundle in AppKernel
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Troopers\CronBundle\CronBundle(),
...
);
return $bundles
Add your configuration in config.yml
. See the following example on for how to customize your commands
troopers_cron:
reporting:
api:
url: 'http://monitoring_api.local/api/cron'
api_key: 'myapikey'
format: form
tasks:
- command: 'help'
schedule: '* * * * *'
arguments:
command_name: 'cache:clear'
- command: 'cache:clear'
schedule: '@daily'
arguments:
--env: 'prod'
--no-debug: null
The reporting
key let you use a reporting tool in order to keep track of tasks execution.
The only tool available for now is the api
.
url
: api url (base uri and api route)api_key
: optional api_key used for authenticationformat
: format used for the data. Only form is implemented. Default value is form
The list of commands to execute.
command
: command to executeschedule
: cron schedulearguments
: list of the command's arguments
Add the following line to your crontab:
* * * * * /path/to/symfony/install/app/console cron:run 1>> /dev/null 2>&1