hzted123 / yii2-cronjobs
Simple and convenient installing console commands as cron jobs for Yii framework
Installs: 3 943
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:yii2-extension
pkg:composer/hzted123/yii2-cronjobs
Requires
- php: >=5.3.0
 - yiisoft/yii2: *
 
This package is not auto-updated.
Last update: 2025-10-30 01:22:42 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 hzted123/yii2-cronjobs "*"
or add
"hzted123/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' => 'hzted123\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.