diff --git a/src/cron/scheduler.rs b/src/cron/scheduler.rs index ce9c6c3..018ab13 100644 --- a/src/cron/scheduler.rs +++ b/src/cron/scheduler.rs @@ -218,11 +218,14 @@ fn warn_if_high_frequency_agent_job(job: &CronJob) { Schedule::Every { every_ms } => *every_ms < 5 * 60 * 1000, Schedule::Cron { .. } => { let now = Utc::now(); - match ( - next_run_for_schedule(&job.schedule, now), - next_run_for_schedule(&job.schedule, now + chrono::Duration::seconds(1)), - ) { - (Ok(a), Ok(b)) => (b - a).num_minutes() < 5, + match next_run_for_schedule(&job.schedule, now) { + Ok(first) => { + // Get the occurrence *after* the first one to measure the actual interval. + match next_run_for_schedule(&job.schedule, first) { + Ok(second) => (second - first).num_minutes() < 5, + _ => false, + } + } _ => false, } }