# Why does schedule-monitor:sync change my cron?

The [spatie/laravel-schedule-monitor](https://github.com/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](https://github.com/spatie/laravel-schedule-monitor?tab=readme-ov-file#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:

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

**Using an unsupported method** — `between` is runtime-only, so Oh Dear sees "every four hours" without the time-window constraint:

```php
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:

```php
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](https://crontab.guru/) is a great playground.
