Skip to content

gofmanaa/yii2-crontask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gofmanaa/yii2-crontask

yii2 cron task manager

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist gofmanaa/yii2-crontask "*"

or add

"gofmanaa/yii2-crontask": "*"

to the require section of your composer.json file.

Requirements

Linux OS Yii2

Usage

Add to console config:

return [
    'bootstrap' => [
        'crontask'
    ],
    'modules' => [
        'crontask' => [
            'class' => 'gofmanaa\crontask\Module',
            'fileName'=>'cron.txt', //optional
            'params'=>[ '2>&1' ], //common params
            'yiiPath' => null // yii execute path
            'phpPath' => '/usr/bin/php', //default php path
            'tasks'=>[
                'dosomething'=>
                            [
                               'params'=>[ '--some=something' , '>/dev/null' ], //task params
                               'command'=>'path/to/controller/action',
                               'min'=>'*/1',
                               'hour'=>'*',
                               'day'=>'*',
                               'month'=>'*',
                               'dayofweek'=>'*',
                            ],
                'dosomething2'=>
                            [
                                'command'=>'path/to/controller/action',
                                'min'=>'*/2',
                            ],
            ]
        ],
    ],
]

Console command

- crontask                    Provides cron information about console commands.
    crontask/index (default)  Displays available commands or the detailed information
    crontask/ls               List App Cron tasks;   crontask/ls a All cron jobs
    crontask/start            Start cron tasks,  "crontask/start dosomething2"  start single task
    crontask/stop             Stop App cron. "crontask/stop 3"  stop task by index 3 
    crontask/restart          Restart cron tasks