PHPackages                             mehr-it/lara-cron - 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. [Database &amp; ORM](/categories/database)
4. /
5. mehr-it/lara-cron

ActiveLibrary[Database &amp; ORM](/categories/database)

mehr-it/lara-cron
=================

Dynamic, user manageable, distributed cron jobs for Laravel

2.3.0(4y ago)1927[4 PRs](https://github.com/mehr-it/lara-cron/pulls)MITPHPPHP &gt;=7.1

Since Apr 4Pushed 3y agoCompare

[ Source](https://github.com/mehr-it/lara-cron)[ Packagist](https://packagist.org/packages/mehr-it/lara-cron)[ RSS](/packages/mehr-it-lara-cron/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (5)Versions (18)Used By (0)

LaraCron - dynamic user cron schedules
======================================

[](#laracron---dynamic-user-cron-schedules)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f8e9d3a284a1332550b6dcf49967f6539edbd4ed1218d3e602ecf754988dd68d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6568722d69742f6c6172612d63726f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mehr-it/lara-cron)[![Build Status](https://camo.githubusercontent.com/bb6fffad86fe48b299e5de3d2af2153b4901a91352d696eb4c0e0b479660c08a/68747470733a2f2f7472617669732d63692e6f72672f6d6568722d69742f6c6172612d63726f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mehr-it/lara-cron)

This package helps to implement user manageable, distributed cron jobs. Cron jobs are stored in a database table and are executed whenever given cron expression matches.

Unlike other cron implementations, this package always uses queuing for dispatching cron jobs. The cron **jobs are sent to the queue** regularly, just a few minutes before they are due - but with a delay, so the jobs won't get received until their desired execution time.

This approach has several advantages:

- Scheduler down time of a view minutes does not cause miss of cron jobs
- Cron jobs can be caught up if missed
- Cron job execution can be distributed over many machines
- You may execute the cron scheduler on multiple machines without to care for duplicate cron job dispatches, because duplicate prevention is already built-in

Usage
-----

[](#usage)

Creating cron schedules is very easy:

```
$cron = new CronExpression('*/15 * * * *', 'Europe/Berlin');

Cron::schedule($cron, $job);

Cron::schedule($cron, $job, 'myJob', 'jobGroup');

```

To update an existing schedule, simply call `schedule()` with same key parameter again.

To delete a cron schedule, simply call the `delete()` method:

```
Cron::delete('myJob');

```

You can also list all cron schedules, optionally filtered by group name:

```
Cron::describeAll();

Cron::describeAll('myGroup');

```

Invoking the scheduler
----------------------

[](#invoking-the-scheduler)

The cron scheduler dispatches all upcoming cron jobs to queue. By default it is invoked by Laravel's Scheduler every five minutes and dispatches cron jobs due within next 10 minutes.

You can disable this behavior by setting:

```
// config/cron.php

'dispatch_schedule' => false,

```

Then you have to invoke `artisan cron:dispatch 600`manually. The `600` specifies the period (in seconds) for which to dispatch the cron jobs for. This value should always be larger than the timespan between these dispatcher calls.

Catchup of missed cron jobs
---------------------------

[](#catchup-of-missed-cron-jobs)

Systems fail. Even cron schedulers. Or systems running the scheduler may be down for some time. Therefore you may specify a catchup timeout for your cron jobs as last parameter.

Cron::schedule($cron, $job, 'my-job', null, true, 300);

The dispatcher will do some catching up for jobs that were due within that period but have not been scheduled yet.

DST handling
------------

[](#dst-handling)

DST (daylight saving time) and cron expressions can be very tricky and different cron implementations may behave differently.

The problem which has to be solved are the skipping of one clock hour at DST start and repeating a clock hour on DST end. Without any special handling, cron jobs might not run at all or being invoked double.

Following describes how this package handles DST clock changes.

### DST start (turning clock from 2:00 to 3:00)

[](#dst-start-turning-clock-from-200-to-300)

On DST start, cron jobs scheduled between 2:00 and 2:59 simply start between 3:00 and 3:59.

This way no cron is missed, but you should beware that some jobs could overlap others which they usually dont.

### DST end (turning clock back from 3:00 to 2:00)

[](#dst-end-turning-clock-back-from-300-to-200)

On DST end, the handling depends on the hour expression in the cron field. If a wildcard or a range matching the period between 2:00 and 3:00 is defined, the cron jobs are run twice. For lists, increments and single values, cron jobs are only run once.

Following table shows which expressions would cause repeating and which not:

repeatednot repeated`0 * * * *``0 2 * * *``30 * * * *``30 2 * * *``0 2-3 * * *``0 2,3 * * *``0 1-4 * * *``0 0-2 * * *``*/5 2 * * *``5 2-12/2 * * *`User input validation
---------------------

[](#user-input-validation)

To validate cron expressions input by users, you may use the included `CronExpressionValidationRule`:

```
$rules = [
	'fieldName' => ['required', new CronExpressionValidationRule()],
]

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity64

Established project with proven stability

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 ~80 days

Recently: every ~108 days

Total

13

Last Release

1680d ago

Major Versions

1.1.0 → 2.0.02019-04-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44973729?v=4)[mehr.IT GmbH](/maintainers/mehr-it)[@mehr-it](https://github.com/mehr-it)

---

Tags

croncrontabdatabasedynamicschedulescheduleruser

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mehr-it-lara-cron/health.svg)

```
[![Health](https://phpackages.com/badges/mehr-it-lara-cron/health.svg)](https://phpackages.com/packages/mehr-it-lara-cron)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11222.5M33](/packages/anourvalar-eloquent-serialize)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135212.4k7](/packages/statamic-rad-pack-runway)[mozex/laravel-scout-bulk-actions

Import, flush, and queue-import all your Laravel Scout searchable models at once. Auto-discovers models, runs in bulk, tracks progress.

1437.7k](/packages/mozex-laravel-scout-bulk-actions)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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