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

ActiveCakephp-plugin

simtecsystem/cake-scheduler
===========================

Cron Scheduler for CakePHP 3

1.0.0(8y ago)03MITPHP

Since Oct 2Pushed 6y agoCompare

[ Source](https://github.com/simtecsystem/cake-scheduler)[ Packagist](https://packagist.org/packages/simtecsystem/cake-scheduler)[ RSS](/packages/simtecsystem-cake-scheduler/feed)WikiDiscussions master Synced 2mo ago

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

CakeScheduler
=============

[](#cakescheduler)

Cron Scheduler Plugin for CakePHP 3

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#installation)
- [Why Use It](#why-use-it)
- [Installation](#installation)
- [Starting The Scheduler](#starting-the-scheduler)
- [Defining Schedules](#defining-schedules)
    - [Scheduling CakePHP Shell](#scheduling-cakephp-shell)
    - [Scheduling Any Other Commands](#scheduling-any-other-commands)
    - [Frequency Options](#frequency-options)
- [Hooks](#hooks)
    - [Before A Job Runs](#before-a-job-runs)
    - [After A Job Is Finished](#after-a-job-is-finished)

Introduction
------------

[](#introduction)

CakeScheduler allows you to write cron jobs right from PHP files. It works for CakePHP shell as well as any other valid PHP code. Basically it is a replacement of the conventional crontab file.

Why Use It
----------

[](#why-use-it)

The conventional way of writing a cron job is to place an entry in the crontab file each time you need to schedule a job. The problem with this approach is that you have to login(SSH) to the server each time.

By using CakeScheduler, we are able to place the cron jobs in the source control system and deploy them to production just like any other PHP code.

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

[](#installation)

- To install the CakeScheduler plugin, you can use composer. From your application's ROOT directory (where composer.json file is located) run the following:

    `composer require simtecsystem/cake-scheduler`
- You will need to add the following line to your application's `config/bootstrap.php` file:

    `Plugin::load('CakeScheduler');`
- You have to export an Cruz Configuration via `vendor/lavary/crunz/crunz publish:config`

Starting The Scheduler
----------------------

[](#starting-the-scheduler)

We only need to install one ordinary cron job which runs every minute. This cron job will enable CakeScheduler to schedule all the subsequent jobs:

`* * * * * /path-to-project/bin/cake cake_scheduler run schedule:run`

Defining Schedules
------------------

[](#defining-schedules)

A schedule is basically a PHP file ending with **Tasks.php** and it must return the **CakeSchedule** object. All schedules should be place inside a folder called **src/Shell/Schedule/**.

For example:

```
// schdule/BackTasks.php
$schedule = new \CakeScheduler\Schedule\CakeSchedule();
$schedule
    ->run('/usr/bin/php backup.php')
    ->daily()
    ->description('Test');
return $schedule;
```

### Scheduling CakePHP Shell

[](#scheduling-cakephp-shell)

To schedule a CakePHP shell, call *CakeSchedule::shell*:

`$schedule->shell('MyCake awesome')`

### Scheduling Any Other Commands

[](#scheduling-any-other-commands)

To schedule any other commands, call *CakeSchedule::run*:

`$cakeSchedule->run('/usr/bin/php backup.php')`

### Frequency Options

[](#frequency-options)

There is plenty of ways to define the frequency of the execution:

MethodDescription-&gt;cron()the classic way of defining a schedule-&gt;hourly()beginning of each hour-&gt;daily()daily at midnight-&gt;weeklysunday of each week-&gt;monthly()first day of each month-&gt;quarterly()first day of each quarter-&gt;yearly()first day of each year-&gt;everyFiveMinutes()every five minutes-&gt;everyMinute()every minute-&gt;everyTwelveHours()every twelve hours-&gt;everyMonth()every month-&gt;everySixMonths()every six months-&gt;everyFifteenDays()every fifteen days-&gt;on('13:30 2016-03-01')at a specific date and time-&gt;at('13:30')at a specific timeUnder the hood, CakeSchedule is using the great [lavary/crunz](https://github.com/lavary/crunz#frequency-of-execution) library. It has a large number of options for us to configure the frequency of the execution. Check out its official documentation if you are looking for more available frequency.

Hooks
-----

[](#hooks)

Hooks make it easy to integrate with other services such as [www.watchowl.io](http://www.watchowl.io).

### Before A Job Runs

[](#before-a-job-runs)

To do something before a job is executed, we can use the *before()* hook:

For example:

```
$schedule = new \CakeScheduler\Schedule\CakeSchedule();

$schedule
    ->run('/usr/bin/php backup.php')
    ->before(function() {
        // Do something before the job runs
     })
    ->daily()
    ->description('Test');

return $schedule;
```

### After A Job Is Finished

[](#after-a-job-is-finished)

To do something before a job is executed, we can use the *before()* hook:

For example:

```
$schedule = new \CakeScheduler\Schedule\CakeSchedule();

$schedule
    ->run('/usr/bin/php backup.php')
    ->after(function() {
        // Do something after the job is finished
     })
    ->daily()
    ->description('Test');

return $schedule;
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

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

Unknown

Total

1

Last Release

3141d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0fa21215cfd3df464f376b331dd62e00a635bd7ed46e3567437ee480b676df61?d=identicon)[simtecsystem](/maintainers/simtecsystem)

---

Top Contributors

[![fiste788](https://avatars.githubusercontent.com/u/1515782?v=4)](https://github.com/fiste788 "fiste788 (13 commits)")[![watchowl](https://avatars.githubusercontent.com/u/32160403?v=4)](https://github.com/watchowl "watchowl (11 commits)")[![dilab](https://avatars.githubusercontent.com/u/218813?v=4)](https://github.com/dilab "dilab (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[friendsofcake/cakepdf

CakePHP plugin for creating and/or rendering Pdfs, several Pdf engines supported.

3752.1M3](/packages/friendsofcake-cakepdf)[cakephp/bake

Bake plugin for CakePHP

11211.2M156](/packages/cakephp-bake)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

338920.1k32](/packages/dereuromark-cakephp-tools)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308850.3k14](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1862.1M26](/packages/dereuromark-cakephp-ide-helper)[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

129228.6k10](/packages/dereuromark-cakephp-tinyauth)

PHPackages © 2026

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