hashicorp/nomad · warning
cron is deprecated and may be removed in a future release. U
Error message
cron is deprecated and may be removed in a future release. Use crons instead
What it means
Job.Validate emits a deprecation warning-style error when a periodic job uses the legacy `cron` field (Periodic.Spec) instead of the newer `crons` list (Periodic.Specs). The message tells the user that `cron` is deprecated and may be removed in a future release.
Source
Thrown at nomad/structs/structs.go:4987
hasAutoPromote = hasAutoPromote || u.AutoPromote
// Having no canaries implies auto-promotion since there are no canaries to promote.
allAutoPromote = allAutoPromote && (u.Canary == 0 || u.AutoPromote)
}
}
// check if we have services with no shutdown delay set
mErr.Errors = append(mErr.Errors, j.generateServiceShutdownDelayWarnings()...)
// Check AutoPromote, should be all or none
if hasAutoPromote && !allAutoPromote {
err := fmt.Errorf("auto_promote must be true for all groups to enable automatic promotion")
mErr.Errors = append(mErr.Errors, err)
}
// cron -> crons
if j.Periodic != nil && j.Periodic.Spec != "" {
err := fmt.Errorf("cron is deprecated and may be removed in a future release. Use crons instead")
mErr.Errors = append(mErr.Errors, err)
}
return mErr.ErrorOrNil()
}
// LookupTaskGroup finds a task group by name
func (j *Job) LookupTaskGroup(name string) *TaskGroup {
if j == nil {
return nil
}
for _, tg := range j.TaskGroups {
if tg.Name == name {
return tg
}
}
return nil
}View on GitHub (pinned to 482b49bf1a)
Solutions
- Replace `cron = "<expr>"` with `crons = ["<expr>"]` in the periodic block.
- If multiple schedules are needed, list them all under crons.
- Grep job templates/repos for `cron =` to remove remaining legacy usages.
Example fix
// before
periodic {
enabled = true
cron = "0 * * * *"
}
// after
periodic {
enabled = true
crons = ["0 * * * *"]
} Defensive patterns
Strategy: validation
Validate before calling
if job.Periodic != nil && job.Periodic.Spec != "" {
return fmt.Errorf("use crons = [...] instead of deprecated cron field")
} Prevention
- Grep job files/templates for `cron =` and migrate to `crons =`.
- Prefer the crons list field in all new specs.
- Track Nomad release notes for scheduled removal of the legacy field.
When it happens
Trigger: Submitting a job whose `periodic` block sets `cron = "..."` (single spec field) rather than `crons = [...]`. Detected via j.Periodic != nil && j.Periodic.Spec != "".
Common situations: Old job files carried forward from pre-crons Nomad versions; tutorials/examples referencing the legacy field; scripts generating periodic jobs from templates that still use `cron`.
Related errors
- Multiple service providers used: task group services must us
- MaxClientDisconnect is deprecated and ignored in favor of Di
- StopAfterClientDisconnect is deprecated and ignored favor of
- PreventRescheduleOnLost is deprecated and ignored in favor o
- must specify cron block
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/021cbd5b8f024020.
Report an issue: GitHub.