Why does schedule-monitor:sync change the expected cron expression?

The spatie/laravel-schedule-monitor package syncs your Laravel schedule to Oh Dear by reading the Laravel Schedule object. Some Laravel scheduler methods can be expressed as a simple cron expression (->everyFourHours(), ->daily(), etc.). Others, like ->between(), ->when(), and other conditional constraints, can't, because they're evaluated at runtime instead of being baked into a crontab-style expression.

When the package encounters one of the unsupported methods, it falls back to the best cron expression it can derive from the rest of the schedule. That's why the synced expression might be broader than what your command actually runs.

Example

Supported, straightforward schedule — runs every four hours, and that's exactly what syncs:

Schedule::command('your-command')
    ->everyFourHours()
    ->thenPing(...);

Using an unsupported methodbetween is runtime-only, so Oh Dear sees "every four hours" without the time-window constraint:

Schedule::command('your-command')
    ->everyFourHours()
    ->between('07:00', '23:00')
    ->thenPing(...);

Oh Dear would expect pings every four hours across the full day, which isn't what the schedule actually does.

The fix: use cron() with an explicit expression

Bypass the inference by giving the package a cron expression directly:

Schedule::command('your-command')
    ->cron('0 7-23/4 * * *')
    ->thenPing(...);

Now the expression in Oh Dear matches reality, and you won't get alerts for "missing" pings that were never supposed to fire.

If you need a hand translating a Laravel schedule into a cron expression, crontab.guru is a great playground.

Related Questions

View all Cron Job Monitoring questions →

Want to get started? We offer a no-strings-attached 10 day trial. No credit card required.

Start monitoring

You're all set in
less than a minute!