Yii2 cron extension
Allows to define and execute cronjobs in Yii2 application, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist comradefuzz/yii2-cron "*"
or add, (*4)
"comradefuzz/yii2-cron": "*"
to the require section of your composer.json
file., (*5)
Usage
Add cron console controller to your config and define your jobs :, (*6)
'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:, (*7)
* * * * * /path/to/yii cron > /dev/null 2>&1