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

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

trentrichardson/cakephp-scheduler
=================================

Makes scheduling tasks in CakePHP much simpler.

3.0.4(10y ago)3137.0k↓15.4%17[3 issues](https://github.com/trentrichardson/cakephp-scheduler/issues)MITPHPPHP &gt;=5.3.6

Since Mar 19Pushed 9y ago6 watchersCompare

[ Source](https://github.com/trentrichardson/cakephp-scheduler)[ Packagist](https://packagist.org/packages/trentrichardson/cakephp-scheduler)[ Docs](http://github.com/trentrichardson/cakephp-scheduler)[ RSS](/packages/trentrichardson-cakephp-scheduler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (11)Used By (0)

CakePHP Scheduler Plugin
========================

[](#cakephp-scheduler-plugin)

Makes scheduling tasks in CakePHP much simpler.

Author
------

[](#author)

Trent Richardson \[\]

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)

This Shell was developed for CakePHP 3.

### Composer Installation (recommended)

[](#composer-installation-recommended)

In your project's composer.json file add this to your require:

```
"trentrichardson/cakephp-scheduler": "~3.0"

```

### Manual Installation

[](#manual-installation)

Copy the Scheduler plugin into your App/Plugin folder and rename the folder to Scheduler.

### Load the Plugin

[](#load-the-plugin)

In your bootstrap.php file add either:

```
Plugin::loadAll();
```

or

```
Plugin::load('Scheduler',['autoload'=>true]);
```

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/2.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(
	'CleanUp' => array('interval' => 'next day 5:00', 'task' => 'CleanUp'),// tomorrow at 5am
	'Newsletters' => array('interval' => 'PT15M', 'task' => 'Newsletter') //every 15 minutes
));
```

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

39

—

LowBetter than 86% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 67.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 ~42 days

Total

8

Last Release

3782d 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/313144?v=4)[Trent Richardson](/maintainers/trentrichardson)[@trentrichardson](https://github.com/trentrichardson)

---

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)")

---

Tags

schedulercakephptaskcron job

### Embed Badge

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

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

###  Alternatives

[peppeocchi/php-cron-scheduler

PHP Cron Job Scheduler

8282.5M34](/packages/peppeocchi-php-cron-scheduler)[symfony/scheduler

Provides scheduling through Symfony Messenger

8910.8M52](/packages/symfony-scheduler)[rewieer/taskschedulerbundle

Task Scheduler with CRON for Symfony

63242.1k](/packages/rewieer-taskschedulerbundle)[ttree/scheduler

Simple task scheduler for Neos Flow Framework

21108.8k1](/packages/ttree-scheduler)[webtoolsnz/yii2-scheduler

A scheduled task runner for Yii2 applications

1881.1k](/packages/webtoolsnz-yii2-scheduler)[glooby/task-bundle

Scheduling of tasks for symfony made simple

3216.3k](/packages/glooby-task-bundle)

PHPackages © 2026

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