PHPackages                             elisteam/yii2-cronjobs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. elisteam/yii2-cronjobs

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

elisteam/yii2-cronjobs
======================

cronjobs

0350PHP

Since Feb 15Pushed 10y ago1 watchersCompare

[ Source](https://github.com/elisteam/yii2-cronjobs)[ Packagist](https://packagist.org/packages/elisteam/yii2-cronjobs)[ RSS](/packages/elisteam-yii2-cronjobs/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Yii2 cronjobs extension
=======================

[](#yii2-cronjobs-extension)

Easiest way to put crontab on your console scripts.

This extension is based on [this](https://github.com/Yiivgeny/Yii-PHPDocCrontab). Thanks [Yiivgeny](https://github.com/Yiivgeny).

And next, [Denis](https://github.com/DenisOgr) has adapted it for yii2. I was only updated it for my needs and continue developing.

Changes from origin:

- Work with yii2
- Set config in params (not in phpDocs).

[Denis](https://github.com/DenisOgr) transfer ​​settings of crontab in local settings(params) configuration, so that the application can be run on different servers with different sets of crontab.

Installation
------------

[](#installation)

#### Step 1

[](#step-1)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Next, need to run:

```
composer require --prefer-dist elisteam/yii2-cronjobs "dev-master"
```

or add:

```
...
"require": {
    ...
    "elisteam/yii2-cronjobs": "dev-master"
}
```

to the require section of your `composer.json` file.

#### Step 2: Set aliase

[](#step-2-set-aliase)

Set aliase @runnerScript in console config. This absolutely path to runner script (I can not find another way to get runner script). Change path to runner script as your project.

```
Yii::setAlias('@runnerScript', dirname(dirname(dirname(__FILE__))) .'/yii');
```

#### Step 3: Add to console config

[](#step-3--add-to-console-config)

Edit this file (or ohter your own console config):

```
config/console.php
```

```
return [
    //...
    'controllerMap' => [
    	'cron' => [
    	    'class' => 'elisteam\cronjobs\CronController'
    	],
    ],
]
```

#### Step 4: Add task to system scheduler

[](#step-4-add-task-to-system-scheduler)

Add task to system scheduler (cron on unix, task scheduler on windows) to run every minute:

```
* * * * * /path/to/yii/application/protected/yii cron
```

Usage
-----

[](#usage)

Add in params array with cron sets:

```
'cronJobs' =>[
    'test/example1' => [
    	'cron'      => '* * * * *',
    ],
    'test/example2' => [
    	'cron'      => '10 * * * *',
    ],
],
```

You can point any settings from [this](https://github.com/Yiivgeny/Yii-PHPDocCrontab/blob/master/examples/ExampleRuCommand.php).

### More usage examples

[](#more-usage-examples)

##### 1 Use log path for stdout:

[](#1-use-log-path-for-stdout)

```
/**
 * Parameters stdout and stderr can be a mask including next variables:
 *     %L - yii2 logsDir
 *     %C - command name
 *     %A - action name
 *     %P - PID of running process
 *     %D(format) - date format; the same sintax as that date()
 *
 */
 return [
    'cronJobs' =>[
    	'test/example1' => [
    	    'cron'        => '* * * * *',
    	    'cron-stdout' => '/tmp/Example_%C.%A.log'
    	],
    ]
]
```

##### 2 Using custom stderr:

[](#2-using-custom-stderr)

```
return [
    'cronJobs' =>[
    	'test/example2' => [
    	    'cron'        => '* * * * *',
    	    'cron-stdout' => '/tmp/Example_%C.%A.log',
    	    'cron-stderr' => '/tmp/ExampleCommandError.log'
    	],
    ]
]
```

##### 3 Using args:

[](#3-using-args)

```
return [
    'cronJobs' =>[
    	'test/example2' => [
    	    'cron'        => '* * * * *',
    	    'cron-args' => '--limit=5 --offset=10'
    	],
    ]
]
```

##### 4 Using tags:

[](#4-using-tags)

This will be work only if run command will have a ***dbserver*** or ***cacheserver*** tags. For example:

```
./yii cron run   dbserver storageserver
```

```
return [
    'cronJobs' =>[
    	'test/example2' => [
    	    'cron'        => '* * * * *',
    	    'cron-tags' => 'dbserver cacheserver'
    	],
    ]
]
```

##### 5 Using extended time format:

[](#5-using-extended-time-format)

```
return [
    'cronJobs' =>[
    	'test/example2' => [
    	    'cron'        => '10,25-30,40 *\2 15-21,23-27 1-6\2 *'
    	],
    ]
]
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1941dc0465d8c69b3999b26e5f012450973251ec70927599fb6b408d2bdd1f57?d=identicon)[elisteam](/maintainers/elisteam)

---

Top Contributors

[![DenisOgr](https://avatars.githubusercontent.com/u/1311408?v=4)](https://github.com/DenisOgr "DenisOgr (20 commits)")[![elipavlov](https://avatars.githubusercontent.com/u/7875287?v=4)](https://github.com/elipavlov "elipavlov (5 commits)")

### Embed Badge

![Health badge](/badges/elisteam-yii2-cronjobs/health.svg)

```
[![Health](https://phpackages.com/badges/elisteam-yii2-cronjobs/health.svg)](https://phpackages.com/packages/elisteam-yii2-cronjobs)
```

###  Alternatives

[php-coord/php-coord

PHPCoord is a PHP library to aid in handling coordinates. It can convert coordinates for a point from one system to another and also calculate distance between points.

109996.7k12](/packages/php-coord-php-coord)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
