Know when Laravel's schedule:run stops running
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 happens | What Stallbell sees | Alert |
|---|---|---|
The schedule:run cron entry is missing after a server move or rebuild | No heartbeat by the expected time plus grace | Missed run |
Cron runs, but php artisan fails before the scheduler starts (wrong PHP path, a fatal error at boot) | No heartbeat | Missed run |
The app is in maintenance mode (php artisan down) | No heartbeat | Missed run |
| The heartbeat task itself throws | A fail ping from pingOnFailure | Failed run |
| The heartbeat comes back | A check-in after the incident | Recovered |
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:
'stallbell' => [
'heartbeat_url' => env('STALLBELL_HEARTBEAT_URL'),
],Then add the URL from the monitor page to .env:
STALLBELL_HEARTBEAT_URL=https://stallbell.com/p/TOKEN
2. Add the heartbeat to routes/console.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:
* * * * * 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
| Field | Value | Why |
|---|---|---|
| Kind | Scheduled job | A label only. schedule:run is started by cron. |
| How it runs | On a fixed interval | The heartbeat task runs every five minutes, so a fixed interval matches it. |
| Every | 5 minutes | Every 5 minutes, the fastest the Free plan allows. A per-minute ping would fail validation on Free. |
| Grace period | 5 minutes | 5 minutes absorbs a slow schedule:run tick. Silence for 10 minutes means the scheduler stopped. |
| Failures in a row | 1 | The heartbeat does nothing, so one failure means something is wrong with the app. |
| Stuck after | 10 minutes | Not used by the snippet, which pings only after the task. 10 minutes keeps it tight if you add pingBefore. |
Related
- Know when Celery beat or your workers stop
- Know when a nightly pg_dump fails or writes an empty file
- Docs: check-in fields
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.