gofmanaa/yii2-crontask

yii2 定时任务管理器

安装次数: 11,597

依赖者: 0

建议者: 0

安全: 0

星标: 9

关注者: 2

分支: 4

开放问题: 1

类型:yii2-extension

1.4 2018-06-07 13:45 UTC

This package is not auto-updated.

Last update: 2024-09-20 20:41:41 UTC


README

yii2 定时任务管理器

安装

安装此扩展的首选方式是通过 composer.

运行以下命令之一:

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

或者在您的 composer.json 文件的 require 部分添加:

"gofmanaa/yii2-crontask": "*"

to the require section of your composer.json file.

要求

Linux OS Yii2

使用方法

添加到控制台配置

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',
                            ],
            ]
        ],
    ],
]

控制台命令

- 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