Skip to content

comradefuzz/yii2-cron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Yii2 cron extension

Allows to define and execute cronjobs in Yii2 application

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist comradefuzz/yii2-cron "*"

or add

"comradefuzz/yii2-cron": "*"

to the require section of your composer.json file.

Usage

Add cron console controller to your config and define your jobs :

    '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:

* * * * * /path/to/yii cron > /dev/null 2>&1

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages