CronHook
Home / Guides / Laravel
PHP Framework

Laravel Heartbeat Cron Monitoring

Integrate heartbeat ping monitoring into Laravel's Task Scheduler ($schedule). Track scheduled commands and get alerted on failures.

1. Success Ping Setup

Ping when your job completes successfully
Laravel — Success Ping
// In app/Console/Kernel.php or routes/console.php
$schedule->command('emails:send')
    ->dailyAt('02:00')
    ->thenPing('https://cronhook.site/ping/YOUR_CHECK_ID')
    ->onFailurePing('https://cronhook.site/ping/YOUR_CHECK_ID/fail');

2. Failure & Exception Handling

Ping /fail for instant failure dispatch without waiting for timeout
Laravel — Failure Catch
// Custom exception handler notification
use Illuminate\Support\Facades\Http;

try {
    Artisan::call('backup:run');
    Http::get('https://cronhook.site/ping/YOUR_CHECK_ID');
} catch (\Throwable $e) {
    Http::get('https://cronhook.site/ping/YOUR_CHECK_ID/fail');
    throw $e;
}

How to Implement in Laravel

1

Define your scheduled task

In Laravel, add your command to the Scheduler inside App\Console\Kernel.php.

2

Chain thenPing() & onFailurePing()

Use Laravel's built-in scheduler ping methods to automatically notify CronHook on completion or failure.

3

Set grace buffers for long tasks

For heavy tasks like database backups, set a 10-minute grace buffer in CronHook to avoid false alerts during heavy IO.

Pro-Tip for Laravel Developers

Laravel Schedule Monitor: You can also wrap job execution using Artisan event listeners to ping CronHook automatically across all scheduled commands.