comradefuzz/yii2-cron

Allows to define and execute cronjobs in Yii2 application

Installs: 1 904

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.1 2017-06-06 09:36 UTC

This package is not auto-updated.

Last update: 2024-04-14 00:12:40 UTC


README

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