PHPackages                             crabstudio/scheduler - 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. crabstudio/scheduler

ActiveCakephp-plugin[Utility &amp; Helpers](/categories/utility)

crabstudio/scheduler
====================

Makes scheduling tasks in CakePHP much simpler.

3.0.6(10y ago)02.4kMITPHPPHP &gt;=5.3.6

Since Mar 19Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ctlabvn/cakephp-scheduler)[ Packagist](https://packagist.org/packages/crabstudio/scheduler)[ Docs](http://github.com/crabstudio/cakephp-scheduler)[ RSS](/packages/crabstudio-scheduler/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (13)Used By (0)

[![Build Status](https://camo.githubusercontent.com/0cc9dfc66ccbed56f861831e11f2d9885080c36da5f1ccf01772b9ff8c27e795/68747470733a2f2f7472617669732d63692e6f72672f6372616273747564696f2f63616b657068702d7363686564756c65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/crabstudio/cakephp-scheduler) [![Latest Stable Version](https://camo.githubusercontent.com/78b9fd6d8557efae038cc78ea219b923db3ca7ac8e469e6a66d58f95611b8b40/68747470733a2f2f706f7365722e707567782e6f72672f6372616273747564696f2f7363686564756c65722f762f737461626c65)](https://packagist.org/packages/crabstudio/scheduler) [![Total Downloads](https://camo.githubusercontent.com/9cd5895777ce2a917c6d54f003f8dd8faa87478c1c6b52a9c6ca62b769c88bec/68747470733a2f2f706f7365722e707567782e6f72672f6372616273747564696f2f7363686564756c65722f646f776e6c6f616473)](https://packagist.org/packages/crabstudio/scheduler) [![Latest Unstable Version](https://camo.githubusercontent.com/d34d4d487e78c141965bce74421930650a6ed637bef3c500c3849173bcc81b13/68747470733a2f2f706f7365722e707567782e6f72672f6372616273747564696f2f7363686564756c65722f762f756e737461626c65)](https://packagist.org/packages/crabstudio/scheduler) [![License](https://camo.githubusercontent.com/798f0db26252d2bd26dc57a8ffe55a07ab6b77a87ea2cfbc221436f0906110a3/68747470733a2f2f706f7365722e707567782e6f72672f6372616273747564696f2f7363686564756c65722f6c6963656e7365)](https://packagist.org/packages/crabstudio/scheduler)

CakePHP 3: Scheduler Plugin
===========================

[](#cakephp-3-scheduler-plugin)

========================

Makes scheduling tasks in CakePHP much simpler.

Author
------

[](#author)

Trent Richardson \[\]

Contributor
-----------

[](#contributor)

Anh Tuan Nguyen \[\]

License
-------

[](#license)

Copyright 2015 Trent Richardson

You may use this project under MIT license.

How It Works
------------

[](#how-it-works)

SchedulerShell works by scheduling one cron (SchedulerShell) for your project. Then in bootstrap.php you can create intervals for all your tasks. Deploying new scheduled tasks are now much easier; one crontab entry executes all your tasks.

Install
-------

[](#install)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require crabstudio/scheduler

```

Or add the following lines to your application's **composer.json**:

```
"require": {
    "crabstudio/scheduler": "^1.0"
}

```

followed by the command:

```
composer update

```

Load plugin
-----------

[](#load-plugin)

Open `terminal/command line` then enter following command:

```
bin/cake plugin load Scheduler

```

Or add this line to **Your\_project\\config\\bootstrap.php**

```
Plugin::load('Scheduler');

```

Schedule a single system cron by the shortest interval you need for SchedulerShell.php. For example, if you have 5 tasks and the most often run is every 5 minutes, then schedule this cron to run at least every 5 minutes. For more help see [Shells as Cron Jobs](http://book.cakephp.org/3.0/en/console-and-shells/cron-jobs.html).

Example cron job:

```
*/5 * * * * cd /path/to/app && bin/cake Scheduler.Scheduler

```

This would run the SchedulerShell every 5 minutes.

Now once this shell is scheduled we are able to add our entries to bootstrap.php. Lets say we want to schedule a CleanUp task daily at 5am and a NewsletterTask for every 15 minutes.

```
Configure::write('SchedulerShell.jobs', array(
	'task_01' => array('interval' => 'next day 5:00', 'task' => 'EmailQueue'),// tomorrow at 5am
	'task_02' => array('interval' => 'PT15M', 'task' => 'Newsletter') //every 15 minutes
));
```

[DateInterval](http://www.php.net/manual/en/class.dateinterval.php)
-------------------------------------------------------------------

[](#dateinterval)

```
`PT1S` task will run each 1 Second
`PT1M` task will run each 1 Minute
`PT1H` task will run each 1 Hour
`P1D` task will run each 1 Day
`P1W` task will run each 1 Week
`P1M` task will run each 1 Month
`P1Y` task will run each 1 Year

```

[datetime.formats.relative](http://php.net/manual/en/datetime.formats.relative.php)
-----------------------------------------------------------------------------------

[](#datetimeformatsrelative)

```
`next day 05:00` task will on tomorrow at 05:00
`sunday 05:00` task will on sunday at 05:00
`weekday 05:00` task will on from Mon-Friday at 05:00
`saturday 05:00` task will on Saturday at 05:00
`sun 05:00` task will on Sun at 05:00
`sun 05:00 next month` task will on Sun at 05:00 in next month
`Monday next week 2020-01-01` task will on Monday in next week 2020-01-01

```

The key to each entry will be used to store the previous run. *These must be unique*!

**interval** is set one of two ways.

1. For set times of day we use PHP's [relative time formats](http://www.php.net/manual/en/datetime.formats.relative.php): "next day 5:00".
2. To use an interval to achieve "every 15 minutes" we use [DateInterval](http://www.php.net/manual/en/class.dateinterval.php) string format: "PT15M".

**task** is simply the name of the Task.

There are a couple optional arguments you may pass: "action" and "pass".

**action** defaults to "execute", which is the method name to call in the task you specify.

**pass** defaults to array(), which is the array of arguments to pass to your "action".

```
Configure::write('SchedulerShell.jobs', array(
	'CleanUp' => array('interval' => 'next day 5:00', 'task' => 'CleanUp', 'action' => 'execute', 'pass' => array()),
	'Newsletters' => array('interval' => 'PT15M', 'task' => 'Newsletter', 'action' => 'execute', 'pass' => array())
));
```

Storage of Results
------------------

[](#storage-of-results)

SchedulerShell keeps track of each run in a json file. By default this is stored in TMP and is named "cron\_scheduler.json".

If you need to change either of these you may use:

```
// change the file name
Configure::write('SchedulerShell.storeFile', "scheduler_results.json");
// change the path (note the ending /)
Configure::write('SchedulerShell.storePath', "/path/to/save/");
```

Preventing Simultaneous SchedulerShells Running Same Tasks
----------------------------------------------------------

[](#preventing-simultaneous-schedulershells-running-same-tasks)

By default, the SchedulerShell will exit if it is already running and has been for less than 10 minutes. You can adjust this by setting:

```
// change the number of seconds to wait before running a parallel SchedulerShell; 0 = do not exit
Configure::write('SchedulerShell.processTimeout', 5*60);
```

Other Notes/Known Issues
------------------------

[](#other-notesknown-issues)

- The optional pass arguments have not been thoroughly tested
- PHP prior to version 5.3.6 only used relative datetime for the DateTime::modify() function. This could result in an interval of "next day 5:00" not running if the previous `lastRun` time was 05:02. Therefore this plugin should only be run on PHP &gt;= 5.3.6.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 55.6% 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.

###  Release Activity

Cadence

Every ~47 days

Total

10

Last Release

3692d ago

Major Versions

1.0.0 → 2.0.02015-03-19

2.0.0 → 3.0.02015-04-23

2.0.1 → 3.0.12015-07-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3163410?v=4)[Tuan Nguyen](/maintainers/anhtuank7c)[@anhtuank7c](https://github.com/anhtuank7c)

---

Top Contributors

[![trentrichardson](https://avatars.githubusercontent.com/u/313144?v=4)](https://github.com/trentrichardson "trentrichardson (25 commits)")[![houseoftech](https://avatars.githubusercontent.com/u/297458?v=4)](https://github.com/houseoftech "houseoftech (12 commits)")[![anhtuank7c](https://avatars.githubusercontent.com/u/3163410?v=4)](https://github.com/anhtuank7c "anhtuank7c (8 commits)")

---

Tags

schedulercakephptaskcron jobcrabstudioanhtuank7c

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/crabstudio-scheduler/health.svg)

```
[![Health](https://phpackages.com/badges/crabstudio-scheduler/health.svg)](https://phpackages.com/packages/crabstudio-scheduler)
```

###  Alternatives

[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

3361.0M51](/packages/dereuromark-cakephp-tools)[peppeocchi/php-cron-scheduler

PHP Cron Job Scheduler

8412.7M37](/packages/peppeocchi-php-cron-scheduler)[cakephp/bake

Bake plugin for CakePHP

11212.0M194](/packages/cakephp-bake)[trentrichardson/cakephp-scheduler

Makes scheduling tasks in CakePHP much simpler.

3241.7k](/packages/trentrichardson-cakephp-scheduler)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308954.9k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M41](/packages/dereuromark-cakephp-ide-helper)

PHPackages © 2026

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