Allows to define and execute cronjobs in Yii2 application
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist comradefuzz/yii2-cron "*"
or add
"comradefuzz/yii2-cron": "*"
to the require section of your composer.json
file.
Add cron console controller to your config and define your jobs :
'controllerMap' => [
'cron' => [
'class' => 'comradefuzz
\yii2cron\CronController',
'crontab' => [
['* * * * *', 'yii app/my-useful-action'],
['* * * * *', 'echo "ONE MORE"'],
['*/5 * * * *', 'echo "Not so fast"'],
],
'log' => true, // Enables logging (default `false`)
'logCategory' => 'crontab', // Log category (default `crontab`)
],
]
Then configure your server crontab:
* * * * * /path/to/yii cron > /dev/null 2>&1