PHPackages                             spatie/laravel-short-schedule - 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. spatie/laravel-short-schedule

Abandoned → Laravel's Scheduler now supports sub-minute scheduled tasksLibrary[Utility &amp; Helpers](/categories/utility)

spatie/laravel-short-schedule
=============================

Schedule artisan commands to run using a sub-minute frequency

1.7.0(1mo ago)6471.1M↓13.9%551MITPHPPHP ^8.3CI passing

Since Jun 5Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/spatie/laravel-short-schedule)[ Packagist](https://packagist.org/packages/spatie/laravel-short-schedule)[ Docs](https://github.com/spatie/laravel-short-schedule)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-laravel-short-schedule/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (17)Versions (27)Used By (1)

Note

As the [Laravel Scheduler now supports sub-minute scheduled tasks](https://laravel.com/docs/11.x/scheduling#sub-minute-scheduled-tasks), this package is no longer needed.

Schedule artisan commands to run at a sub-minute frequency
==========================================================

[](#schedule-artisan-commands-to-run-at-a-sub-minute-frequency)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1ed3e0e7cf0a0debdcc733750003b1adaf07284e887c414c6247cb830616de08/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d73686f72742d7363686564756c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-short-schedule)[![Tests](https://github.com/spatie/laravel-short-schedule/workflows/Tests/badge.svg)](https://github.com/spatie/laravel-short-schedule/workflows/Tests/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/95b3286af1e89a57188963abfe249a575ae3c981f3a218f3bca3a21b084db493/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d73686f72742d7363686564756c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-short-schedule)

[Laravel's native scheduler](https://laravel.com/docs/master/scheduling) allows you to schedule Artisan commands to run every minute.

If you need to execute something with a higher frequency, for example every second, than you've come to the right package. With laravel-short-schedule installed, you can do this:

```
// in your routes/console.php file

use Spatie\ShortSchedule\Facades\ShortSchedule;

// this command will run every second
ShortSchedule::command('artisan-command')->everySecond();

// this command will run every 30 seconds
ShortSchedule::command('another-artisan-command')->everySeconds(30);

// this command will run every half a second
ShortSchedule::command('another-artisan-command')->everySeconds(0.5);
```

Alternatively, you could add this to the `shortSchedule` method in your console kernel:

```
// in app\Console\Kernel.php

protected function shortSchedule(\Spatie\ShortSchedule\ShortSchedule $shortSchedule)
{
    // this command will run every second
    $shortSchedule->command('artisan-command')->everySecond();

    // this command will run every 30 seconds
    $shortSchedule->command('another-artisan-command')->everySeconds(30);

    // this command will run every half a second
    $shortSchedule->command('another-artisan-command')->everySeconds(0.5);

    // this command will run every second and its signature will be retrieved from command automatically
    $shortSchedule->command(\Spatie\ShortSchedule\Tests\Unit\TestCommand::class)->everySecond();
}
```

Are you a visual learner?
-------------------------

[](#are-you-a-visual-learner)

In [this video](https://spatie.be/videos/laravel-package-training/laravel-short-schedule-part-1-using-the-package) you'll see a demonstration of the package.

Want to know how it works under the hood? Then watch [this video](https://spatie.be/videos/laravel-package-training/laravel-short-schedule-part-2-under-the-hood).

Finally, there's [this video](https://spatie.be/videos/laravel-package-training/laravel-short-schedule-part-3-testing-the-package) that shows how the package is tested. You'll learn how you can test [ReactPHP](https://reactphp.org) powered loops.

These videos are also part of the [Laravel Package Training](https://laravelpackage.training).

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/c7a92146175882de8f017f688bab638e7b76da4f2221938bf67605273f2d733b/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d73686f72742d7363686564756c652e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-short-schedule)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-short-schedule
```

In your production environment you can start the short scheduler with this command

```
php artisan short-schedule:run
```

You should use a process monitor like [Supervisor](http://supervisord.org/index.html) to keep this task going at all times, and to automatically start it when your server boots. Whenever you change the schedule, you should restart this command.

Handle memory leaks
-------------------

[](#handle-memory-leaks)

To deal with commands that leak memory, you can set the lifetime in seconds of the short schedule worker:

```
php artisan short-schedule:run --lifetime=60 // after 1 minute the worker will be terminated
```

After the given amount of seconds, the worker and all it's child processes will be terminated, freeing all memory. Then supervisor (or similar watcher) will bring it back.

### Lumen

[](#lumen)

Before you can run the `php artisan short-schedule:run` command in your Lumen project, you should make a copy of the `ShortScheduleRunCommand` into your `app/Commands` folder:

```
cp ./vendor/spatie/laravel-short-schedule/src/Commands/ShortScheduleRunCommand.php ./app/Console/Commands/ShortScheduleRunCommand.php
```

Next, edit the new `ShortScheduleRunCommand.php` file, and change the namespace from `namespace Spatie\ShortSchedule\Commands;` to `namespace App\Console\Commands;` and you're good to go!

Usage
-----

[](#usage)

Un your routes/console.php file, you can use the `ShortSchedule` facade to schedule commands.

```
// in your routes/console.php file

use Spatie\ShortSchedule\Facades\ShortSchedule;

ShortSchedule::command('artisan-command')->everySecond();
```

In `app\Console\Kernel` you should add a method named `shortSchedule`.

```
// in app\Console\Kernel.php

protected function shortSchedule(\Spatie\ShortSchedule\ShortSchedule $shortSchedule)
{
    // this artisan command will run every second
    $shortSchedule->command('artisan-command')->everySecond();

    // this artisan command will run every second, its signature will be resolved from container
    $shortSchedule->command(\Spatie\ShortSchedule\Tests\Unit\TestCommand::class)->everySecond();
}
```

### Specify the amount of seconds

[](#specify-the-amount-of-seconds)

You can run an artisan command every single second like this:

```
ShortSchedule::command('artisan-command')->everySecond();
```

You can specify a specific amount of seconds using `everySeconds`

```
ShortSchedule::command('artisan-command')->everySeconds(30);
```

You can even schedule tasks at sub-second frequency. This task will run every half a second.

```
ShortSchedule::command('artisan-command')->everySeconds(0.5);
```

### Scheduling shell commands

[](#scheduling-shell-commands)

Use `exec` to schedule a bash command.

```
ShortSchedule::exec('bash-command')->everySecond();
```

### Preventing overlaps

[](#preventing-overlaps)

By default, a scheduled command will run, even if the previous invocation is still running.

You can prevent that by tacking on `withoutOverlapping`

```
ShortSchedule::command('artisan-command')->everySecond()->withoutOverlapping();
```

### Between time constraints

[](#between-time-constraints)

Limit the task to run between start and end times.

```
ShortSchedule::command('artisan-command')->between('09:00', '17:00')->everySecond();
```

It is safe use overflow days. In this example the command will run on every second between 21:00 and 01:00

```
ShortSchedule::command('artisan-command')->between('21:00', '01:00')->everySecond();
```

### Truth test constraints

[](#truth-test-constraints)

The command will run if the given closure return a truthy value. The closure will be evaluated at the same frequency the command is scheduled. So if you schedule the command to run every second, the given closure will also run every second.

```
ShortSchedule::command('artisan-command')->when(fn() => rand() %2)->everySecond();
```

### Environment constraints

[](#environment-constraints)

The command will only run on the given environment.

```
ShortSchedule::command('artisan-command')->environments('production')->everySecond();
```

You can also pass an array:

```
ShortSchedule::command('artisan-command')->environments(['staging', 'production'])->everySecond();
```

### Composite constraints

[](#composite-constraints)

You can use all constraints mentioned above at once. The command will only execute if all the used constraints pass.

```
ShortSchedule::command('artisan-command')
  ->between('09:00', '17:00')
  ->when($callable)
  ->everySecond();
```

### Maintenance Mode

[](#maintenance-mode)

Commands won't run whilst Laravel is in maintenance mode. If you would like to force a command to run in maintenance mode you can use the `runInMaintenanceMode` method.

```
ShortSchedule::command('artisan-command')->everySecond()->runInMaintenanceMode();
```

### Running Tasks On One Server

[](#running-tasks-on-one-server)

Limit commands to only run on one server at a time.

```
ShortSchedule::command('artisan-command')->everySecond()->onOneServer();
```

Events
------

[](#events)

Executing any code when responding to these events is blocking. If your code takes a long time to execute, all short scheduled jobs will be delayed. We highly recommend to put any code you wish to execute in response to these events on a queue.

#### `Spatie\ShortSchedule\Events\ShortScheduledTaskStarting`

[](#spatieshortscheduleeventsshortscheduledtaskstarting)

This event will be fired right before a task will be started. It has these public properties:

- `command`: the command string that will be executed
- `process`: the instance of `Symfony\Component\Process\Process` that will be used to execute the command

#### `Spatie\ShortSchedule\Events\ShortScheduledTaskStarted`

[](#spatieshortscheduleeventsshortscheduledtaskstarted)

This event will be fired right before a task has been started. It has these public properties:

- `command`: the command string that is being executed
- `process`: the instance of `Symfony\Component\Process\Process` that is executing the command

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

69

—

FairBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity61

Solid adoption and visibility

Community30

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 77.3% 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 ~92 days

Recently: every ~169 days

Total

24

Last Release

53d ago

Major Versions

0.0.3 → 1.0.02020-06-07

PHP version history (5 changes)0.0.1PHP ^7.4

1.3.0PHP ^7.4|^8.0

1.4.4PHP ^8.0

1.6.0PHP ^8.2

1.7.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (136 commits)")[![lionslair](https://avatars.githubusercontent.com/u/832259?v=4)](https://github.com/lionslair "lionslair (10 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (7 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![ariddlestone](https://avatars.githubusercontent.com/u/1448695?v=4)](https://github.com/ariddlestone "ariddlestone (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (2 commits)")[![Nutickets](https://avatars.githubusercontent.com/u/57409655?v=4)](https://github.com/Nutickets "Nutickets (1 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (1 commits)")[![sanmai](https://avatars.githubusercontent.com/u/139488?v=4)](https://github.com/sanmai "sanmai (1 commits)")[![TimGeDev](https://avatars.githubusercontent.com/u/9255868?v=4)](https://github.com/TimGeDev "TimGeDev (1 commits)")[![tpaksu](https://avatars.githubusercontent.com/u/3295?v=4)](https://github.com/tpaksu "tpaksu (1 commits)")[![yoeriboven](https://avatars.githubusercontent.com/u/4047804?v=4)](https://github.com/yoeriboven "yoeriboven (1 commits)")[![benholmen](https://avatars.githubusercontent.com/u/1056188?v=4)](https://github.com/benholmen "benholmen (1 commits)")[![daika7ana](https://avatars.githubusercontent.com/u/11703528?v=4)](https://github.com/daika7ana "daika7ana (1 commits)")[![dima-bzz](https://avatars.githubusercontent.com/u/8027583?v=4)](https://github.com/dima-bzz "dima-bzz (1 commits)")[![Jamesking56](https://avatars.githubusercontent.com/u/253237?v=4)](https://github.com/Jamesking56 "Jamesking56 (1 commits)")[![jamieshiers](https://avatars.githubusercontent.com/u/566454?v=4)](https://github.com/jamieshiers "jamieshiers (1 commits)")[![justijndepover](https://avatars.githubusercontent.com/u/9008623?v=4)](https://github.com/justijndepover "justijndepover (1 commits)")

---

Tags

laravelphpschedulesub-minutespatielaravel-short-schedule

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/spatie-laravel-short-schedule/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-short-schedule/health.svg)](https://phpackages.com/packages/spatie-laravel-short-schedule)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-settings

Store your application settings

1.5k5.9M72](/packages/spatie-laravel-settings)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[spatie/laravel-schedule-monitor

Monitor scheduled tasks in a Laravel app

9815.7M9](/packages/spatie-laravel-schedule-monitor)

PHPackages © 2026

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