Skip to content
Knowledge base

Monitor the Laravel scheduler with a heartbeat

Laravel can ping a URL when a scheduled task succeeds or fails. Point those pings at a heartbeat and you hear about a failed task, and about a server whose schedule:run cron line went missing.

1. Create one heartbeat per task you care about

Add a monitor with Check type Heartbeat (cron), set the interval to the task's frequency (86400 seconds for daily()) and a grace period for its run time, and copy the ping URL into your .env, for example REALUPTIME_BACKUP_PING.

2. Use pingOnSuccess and pingOnFailure

Laravel's documented ping methods map straight onto the heartbeat's endpoints: Schedule::command('backup:run')->daily()->pingOnSuccess(env('REALUPTIME_BACKUP_PING'))->pingOnFailure(env('REALUPTIME_BACKUP_PING').'/fail'); Laravel counts a non-zero exit code as a failure, so a failed backup marks the monitor down at once. pingBefore can send the /start ping if you want run durations.

3. Catch a scheduler that is not running at all

Every scheduled task depends on one system cron entry that runs php artisan schedule:run every minute. If a server rebuild drops that line, no task runs and no ping is sent, so each heartbeat goes down at its deadline. For the fastest signal, add a heartbeat on a frequent task, such as one scheduled everyFiveMinutes() with a 300-second interval.

4. Pair it with error tracking

The heartbeat says a task failed; RealUptime Errors, which accepts the Sentry SDK including sentry-laravel, says why. Both are free to start on the same account.

Go deeper

The full reference lives in the docs: Heartbeat monitors documentation. Error codes named above are each explained in the error-code reference.