PHPackages                             matfish/craft-console-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. [CLI &amp; Console](/categories/cli)
4. /
5. matfish/craft-console-scheduler

ActiveCraft-plugin[CLI &amp; Console](/categories/cli)

matfish/craft-console-scheduler
===============================

Schedule Console Commands in Code

2.1.0(1y ago)120proprietaryPHP

Since Jan 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/matfish2/craft-console-scheduler)[ Packagist](https://packagist.org/packages/matfish/craft-console-scheduler)[ RSS](/packages/matfish-craft-console-scheduler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (7)Used By (0)

Console Scheduler
=================

[](#console-scheduler)

This package adds the ability to schedule console commands directly from code.

Why?
----

[](#why)

While you may write a cron configuration entry for each task you need to schedule on your server, this can quickly become a pain, because your task schedule is not recorded to source control and you must SSH into your server to view your existing cron entries, add additional entries or change the schedule.

This package will allow you to:

1. Define only one command in `crontab` and the rest will be handled in code.
2. Use intuitive and readable fluent syntax to define the frequency.
3. Log all executed commands to a dedicated `console-scheduler-{date}.log` file, along with any output the command may generate and the exit code.

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

[](#installation)

1. Include the package:

```
composer require matfish/craft-console-scheduler

```

2. Install the plugin:

```
php craft plugin/install console-scheduler

```

Initial Setup
-------------

[](#initial-setup)

Add the following line to your `crontab`

```
* * * * * /var/www/my-site/php craft console-scheduler/schedule >> /dev/null 2>&1

```

This will ensure the scheduler runs every minute, and checks for due commands to run. It is recommended to set the frequency according to the highest frequency your project requires. E.g if the most frequent command you have runs hourly, there is no need to call the scheduler every minute, and you can use `0 * * * *` instead

Usage
-----

[](#usage)

1. Create a `config/console-scheduler.php` file
2. Add schedules according to the following example:

```
return [
    'schedules' => static function (\matfish\ConsoleScheduler\Schedule\SchedulesCollection $schedule) {
        $schedule->command('activity-logs/logs/prune --days=30 --interactive=0')->monthly();
        $schedule->command('cache/clear')->daily()->at('23:00');
    }
];
```

Supported frequencies:

- `everyMinute()`
- `everyTwoMinutes()`
- `everyThreeMinutes()`
- `everyFourMinutes()`
- `everyFiveMinutes()`
- `everyTenMinutes()`
- `everyFifteenMinutes()`
- `everyThirtyMinutes()`
- `hourly()`
- `hourlyAt($time)`
- `everyOddHour()`
- `everyTwoHours()`
- `everyThreeHours()`
- `everyFourHours()`
- `everySixHours()`
- `daily()`
- `dailyAt($time)`
- `twiceDaily($hour1 = 1,$hour2 = 13)`
- `twiceDailyAt($hour1 = 1,$hour2 = 13, $offset = 0)`
- `weekdays()`
- `weedends()`
- `days($day1,$day2, $day3, etc)` - specific days of week
- `sundays()`
- `mondays()`
- `tuesdays()`
- `wednesdays()`
- `thrusdays()`
- `fridays()`
- `satrudays()`
- `weekly()`
- `weeklyOn($dayOfWeek, $time = '0:0')`
- `monthly()`
- `monthlyOn($dayOfMonth, $time)`
- `twiceMonthly($firstDay = 1, $secondDay = 16, $time = '0:0')`
- `lastDayOfMonth($time = '0:0')`
- `quarterly()`
- `quarterlyOn($dayOfQuarter = 1, $time = '0:0')`
- `yearly()`
- `yearlyOn($month = 1, $dayOfMonth = 1, $time = '0:0')`

Methods without a specified time can be followed by an `at` method using fluent syntax.

If you need more control you can also use the raw `cron` method to define your own frequency, e.g:

```
$schedule->command('my/cool/command')->cron('*/5 * 3 7 4'); // Every 5 minutes, on day 3 of the month, and on Thursday, only in July
```

Testing
-------

[](#testing)

When `CRAFT_ENVIRONMENT=dev` you can pass a `--test` option to the scheduler (in Y-m-d H:i format), to mimic a time which is not the present, and make sure the commands run as expected. E.g:

```
php craft console-scheduler/schedule --test="2024-01-26 19:05"

```

The `--test` option will be ignored in any other environment.

License
-------

[](#license)

You can try Console Scheduler in a development environment for as long as you like. Once your site goes live, you are required to purchase a license for the plugin. License is purchasable through the [Craft Plugin Store](https://plugins.craftcms.com/console-scheduler).

For more information, see Craft's [Commercial Plugin Licensing](https://craftcms.com/docs/4.x/plugins.html#commercial-plugin-licensing).

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 4.0.0 or later.

Acknowledgements
----------------

[](#acknowledgements)

This package is heavily inspired by Laravel's [Task Scheduling](https://laravel.com/docs/11.x/scheduling) feature.

Contribution Guidelines
-----------------------

[](#contribution-guidelines)

Community is at the heart of open-source projects. We are always happy to receive constructive feedback from users to incrementally improve the product and/or the documentation.

Below are a few simple rules that are designed to facilitate interactions and prevent misunderstandings:

Please only open a new issue for bug reports. For feature requests and questions open a new [Discussion](https://github.com/matfish2/craft-console-scheduler/discussions) instead, and precede \[FR\] to the title.

If you wish to endorse an existing FR please just vote the OP up, while refraining from +1 replies.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance46

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~99 days

Total

5

Last Release

435d ago

Major Versions

1.0.2 → 2.0.02024-04-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef7c699ed71e1fdeb389a1aba23f26d02a0a9b7554dd9b8375b739c0357f7339?d=identicon)[matfish2](/maintainers/matfish2)

---

Top Contributors

[![matfish3](https://avatars.githubusercontent.com/u/58558031?v=4)](https://github.com/matfish3 "matfish3 (17 commits)")

---

Tags

craft4craftcmscraftcms-plugincron-jobscrontabschedulerconsoleschedulecommand

### Embed Badge

![Health badge](/badges/matfish-craft-console-scheduler/health.svg)

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

###  Alternatives

[helhum/typo3-console

A reliable and powerful command line interface for TYPO3 CMS

2939.0M192](/packages/helhum-typo3-console)[adhocore/cli

Command line interface library for PHP

3501.2M50](/packages/adhocore-cli)[aplus/cli

Aplus Framework CLI Library

2301.7M6](/packages/aplus-cli)[illuminated/console-mutex

Mutex for Laravel Console Commands.

146938.2k1](/packages/illuminated-console-mutex)[shapecode/cron-bundle

This bundle provides scheduled execution of Symfony commands

59493.0k2](/packages/shapecode-cron-bundle)[laminas/laminas-cli

Command-line interface for Laminas projects

563.7M54](/packages/laminas-laminas-cli)

PHPackages © 2026

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