mitalcoi / yii2-cronjobs
Simple and convenient installing console commands as cron jobs for Yii framework
Installs: 3 031
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 30
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2018-03-08 16:40:40 UTC
README
Easiest way to put crontab on your console scripts.
This extension is based on this. Thanks Yiivgeny.
But with a few changes:
- Work eith yii2
- Set config in params (not in phpDocs).
Installation
- Step 1: The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist mitalcoi/yii2-cronjobs "*"
or add
"mitalcoi/yii2-cronjobs": "*"
to the require section of your composer.json
file.
- Step 2: Set aliase @runnerScript in console config. This absolutely path to runner script Change path to runner script as your project.
Yii::setAlias('@runnerScript', dirname(__DIR__) . '/yii');
- Step 3: Add to console config:
'controllerMap' => [
'cron' => [
'class' => 'mitalcoi\cronjobs\CronController',
'cronJobs' =>[
'test/example1' => [
'cron' => '* * * * *',
],
'test/example2' => [
'cron' => '10 * * * *',
],
],
],
],
- Step 4: Add task to system scheduler (cron on unix, task scheduler on windows) to run every minute:
* * * * * /path/to/yii/application/protected/yiic cron
You can point any settings from this.