Know when Laravel's schedule:run stops running

Updated 3 min read

On this page
  1. The problem
  2. What goes wrong silently
  3. Setup
  4. Recommended settings
  5. Related
  6. FAQ

Stallbell gets a ping from Laravel's scheduler every 5 minutes, and emails you if it stops, so you hear about a dead scheduler before your users notice the missing emails. Pro, Scale and beta accounts can use 5 minutes. On Free, which checks a fixed interval as often as every 15 minutes, use everyFifteenMinutes().

The problem

Laravel runs every scheduled command from one cron entry: * * * * * cd /path-to-your-project && php artisan schedule:run. Move to a new server, rebuild a container or redeploy with a different user, and that line can quietly disappear. Then every scheduled command stops at once: queued emails, cleanups, reports, subscription renewals. Nothing errors, because nothing runs.

This page is a ready-made setup for one scenario.

What goes wrong silently

What Stallbell catches
What happensWhat Stallbell seesAlert
The schedule:run cron entry is missing after a server move or rebuildNo heartbeat by the expected time plus graceMissed run
Cron runs, but php artisan fails before the scheduler starts (wrong PHP path, a fatal error at boot)No heartbeatMissed run
The app is in maintenance mode (php artisan down)No heartbeatMissed run
The heartbeat task itself throwsA fail ping from pingOnFailureFailed run
The heartbeat comes backA check-in after the incidentRecovered

Creates a monitor called laravel-scheduler-heartbeat with the settings below. You can change everything later.

Setup

Laravel's scheduler can ping a URL after a task with pingOnSuccess and pingOnFailure. Use them on a task that does nothing, so the only thing it proves is that schedule:run ran.

1. Put the ping URL in config. In config/services.php, inside the returned array:

PHP
'stallbell' => [
    'heartbeat_url' => env('STALLBELL_HEARTBEAT_URL'),
],

Then add the URL from the monitor page to .env:

Shell
STALLBELL_HEARTBEAT_URL=https://stallbell.com/p/TOKEN

2. Add the heartbeat to routes/console.php:

PHP
use Illuminate\Support\Facades\Schedule;

Schedule::call(fn () => null)
    ->name('stallbell-heartbeat')
    ->everyFiveMinutes() // on Free: ->everyFifteenMinutes()
    ->pingOnSuccess(config('services.stallbell.heartbeat_url'))
    ->pingOnFailure(config('services.stallbell.heartbeat_url').'/fail');

Use config(), not env(), in routes/console.php. Most deploys run php artisan config:cache, and after that env() returns nothing outside the config files. In our test, a heartbeat built with env() still printed DONE after config:cache, but no ping was sent and the only trace was an error in storage/logs/laravel.log. With config() the ping arrived with the config cached and uncached.

Laravel sends the ping as a GET, which Stallbell counts as a successful run. A failed ping is logged and doesn't stop your other scheduled tasks.

3. Check the cron entry on the server is the one from the Laravel docs:

crontab
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

Within 5 minutes (15 on Free), Recent runs on the monitor page shows an OK run.

Recommended settings
FieldValueWhy
KindScheduled jobA label only. schedule:run is started by cron.
How it runsOn a fixed intervalThe heartbeat task runs every five minutes, so a fixed interval matches it.
Every5 minutesEvery 5 minutes, the fastest the Free plan allows. A per-minute ping would fail validation on Free.
Grace period5 minutes5 minutes absorbs a slow schedule:run tick. Silence for 10 minutes means the scheduler stopped.
Failures in a row1The heartbeat does nothing, so one failure means something is wrong with the app.
Stuck after10 minutesNot used by the snippet, which pings only after the task. 10 minutes keeps it tight if you add pingBefore.

FAQ

Why every 5 minutes and not every minute?

schedule:run itself runs every minute. On a fixed interval, Free checks as often as every 15 minutes, Pro every 5 minutes and Scale every minute. During the beta every account gets Pro limits with every-minute checks. A heartbeat every 5 minutes still tells you within about 10 minutes that the scheduler stopped. On Free, use everyFifteenMinutes() and a 15-minute interval instead.

Will this tell me which scheduled command failed?

No. It only proves schedule:run is running. Give each command that matters its own monitor with pingOnSuccess and pingOnFailure.

What happens during php artisan down?

Laravel doesn't run scheduled tasks in maintenance mode, so the heartbeat stops and you'll get a Missed run. Pause the monitor first for long maintenance, or add evenInMaintenanceMode() to the heartbeat.

We run the scheduler on several servers. Does this still work?

Add onOneServer() so only one server sends the heartbeat. It needs a shared cache (database, memcached, dynamodb or redis), as the Laravel docs explain. The heartbeat then means at least one scheduler is alive. To watch each server, give each its own monitor and URL.