/crontab

Yii2 extension for crontab support

Primary LanguagePHPOtherNOASSERTION

Crontab Extension for Yii 2

This extension adds Crontab setup support.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Requirements

This extension requires Linux OS. 'crontab' should be installed and cron daemon should be running.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yii2tech/crontab

or add

"yii2tech/crontab": "*"

to the require section of your composer.json.

Usage

You can setup cron tab using [[yii2tech\crontab\CronTab]], for example:

use yii2tech\crontab\CronTab;

$cronTab = new CronTab();
$cronTab->setJobs([
    [
        'min' => '0',
        'hour' => '0',
        'command' => 'php /path/to/project/yii some-cron',
    ],
    [
        'line' => '0 0 * * * php /path/to/project/yii another-cron'
    ]
]);
$cronTab->apply();