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

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

queencitycodefactory/cakephp-scheduler
======================================

Makes scheduling tasks in CakePHP much simpler.

3.0.4(10y ago)091MITPHPPHP &gt;=5.3.6

Since Mar 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/QueenCityCodeFactory/cakephp-scheduler)[ Packagist](https://packagist.org/packages/queencitycodefactory/cakephp-scheduler)[ Docs](http://github.com/trentrichardson/cakephp-scheduler)[ RSS](/packages/queencitycodefactory-cakephp-scheduler/feed)WikiDiscussions master Synced 1w 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', [
	'CleanUp' => ['interval' => 'next day 5:00', 'task' => 'CleanUp'],// tomorrow at 5am
	'Newsletters' => ['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 \[\], which is the array of arguments to pass to your "action".

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

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);
```

This works by creating a flag file while the process is running, and deleting this file once it is complete. If the file exists, but is older than the timeout specified the scheduler will continue. Although you shouldn't need to, you can change the name of this file:

```
// change the name of the processing flag file
Configure::write('SchedulerShell.processingFlagFile', '.cron_scheduler_processing_flag');
```

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.

Contributing
------------

[](#contributing)

Contributions are much appreciated. Before you burn up too much time on a fix, check the posted issues, pull requests, and branches to see if someone has addressed the issue.

When making changes keep in mind the `master` branch is always the latest stable version. I do not apply changes directly to this branch, but rather to the cakephp-v\* branches. When the latest cakephp version's branch is stable I tag it and merge it with master.

The quick overview:

- Fork/Checkout the cakephp-v\* branch of the cake version you're applying changes for
- From a terminal `cd` into the directory and run `composer install`
- Write any tests and changes you would like to make
- Run `vendor/bin/phpunit` to verify all tests pass and your code works
- Commit, Push, and send a pull request back to the cakephp-v\* branch

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 77.4% 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/840593?v=4)[Daren Sipes](/maintainers/darensipes)[@darensipes](https://github.com/darensipes)

---

Top Contributors

[![trentrichardson](https://avatars.githubusercontent.com/u/313144?v=4)](https://github.com/trentrichardson "trentrichardson (41 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/queencitycodefactory-cakephp-scheduler/health.svg)

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

###  Alternatives

[peppeocchi/php-cron-scheduler

PHP Cron Job Scheduler

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

Makes scheduling tasks in CakePHP much simpler.

3137.0k](/packages/trentrichardson-cakephp-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)

PHPackages © 2026

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