Skip to content

Cron Monitor for laravelKnow when a cron job did not run, and when it came back.

Getting started

This package watches cron jobs that run outside your laravel application. The job calls one URL when it finishes. A scheduled command checks whether the next ping arrived and marks the monitor as down when it did not.

The overview explains the ping and health check flow. The usage guide lists every endpoint and status.

Requirements

  • PHP 8.3 or newer
  • laravel 13
  • A database table for monitors

Installation

composer require jk-oster/laravel-cron-monitor

Publish the config file and the migration, then migrate:

php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=migrations
php artisan migrate

The package migration is a .php.stub file, so it has to be published before it can run.

Configuration

The published file is config/cron-monitor.php. It sets the API prefix, the notification channels, and the model. Set notifications.mail.to and the Slack webhook before you enable those channels.

'api' => [
    'enabled' => true,
    'prefix' => 'cron-monitor',
    'middleware' => [],
],

The configuration reference lists every key.

Quick start

Create a monitor:

php artisan cron-monitor:create "Nightly invoice export" \
  --frequency=1440 \
  --grace=10 \
  --timezone="Europe/Vienna"

The command prints the hash and the ping URL.

Ping it when the job succeeds:

curl -fsS "https://example.com/cron-monitor/ping/6f1c2f7a-0000-0000-0000-000000000000"

Schedule the health check:

use Illuminate\Support\Facades\Schedule;

Schedule::command('cron-monitor:process-checks')->everyMinute();

The scheduler has to run for the check to happen. Add it to routes/console.php.

Next steps

  • How it works covers hashes, due dates, statuses, and failure reasons.
  • Usage covers the ping endpoints, events, and notifications.
  • Advanced usage covers the JSON sync file, the table schema, and custom models.
  • API reference lists classes, methods, and commands.