hashicorp/nomad · error
Periodic can only be used with %q or %q scheduler
Error message
Periodic can only be used with %q or %q scheduler
What it means
Job.Validate enforces that a periodic job (Periodic.Enabled=true) may only use the batch or sysbatch scheduler types. If the job type is anything else (service/system), Nomad appends 'Periodic can only be used with "batch" or "sysbatch" scheduler' to the validation errors.
Source
Thrown at nomad/structs/structs.go:4857
if j.Type == "system" && tg.Count > 1 {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("Job task group %s has count %d. Count cannot exceed 1 with system scheduler",
tg.Name, tg.Count))
}
}
// Validate the task group
for _, tg := range j.TaskGroups {
if err := tg.Validate(j); err != nil {
outer := fmt.Errorf("Task group %s validation failed: %v", tg.Name, err)
mErr.Errors = append(mErr.Errors, outer)
}
}
// Validate periodic is only used with batch or sysbatch jobs.
if j.IsPeriodic() && j.Periodic.Enabled {
if j.Type != JobTypeBatch && j.Type != JobTypeSysBatch {
mErr.Errors = append(mErr.Errors, fmt.Errorf(
"Periodic can only be used with %q or %q scheduler", JobTypeBatch, JobTypeSysBatch,
))
}
if err := j.Periodic.Validate(); err != nil {
mErr.Errors = append(mErr.Errors, err)
}
}
if j.IsParameterized() {
if j.Type != JobTypeBatch && j.Type != JobTypeSysBatch {
mErr.Errors = append(mErr.Errors, fmt.Errorf(
"Parameterized job can only be used with %q or %q scheduler", JobTypeBatch, JobTypeSysBatch,
))
}
if err := j.ParameterizedJob.Validate(); err != nil {
mErr.Errors = append(mErr.Errors, err)View on GitHub (pinned to 482b49bf1a)
Solutions
- Set `type = "batch"` (or "sysbatch") on the job.
- Or remove/disable the `periodic` block if the job should run continuously.
- Run `nomad job validate` to confirm before submitting.
Example fix
// before
job "backup" {
type = "service"
periodic { enabled = true; crons = ["0 * * * *"] }
}
// after
job "backup" {
type = "batch"
periodic { enabled = true; crons = ["0 * * * *"] }
} Defensive patterns
Strategy: validation
Validate before calling
if job.IsPeriodic() && job.Periodic.Enabled &&
job.Type != "batch" && job.Type != "sysbatch" {
return fmt.Errorf("periodic job must be type batch or sysbatch, got %q", job.Type)
} Prevention
- Set `type = "batch"` whenever adding a periodic block.
- Never copy periodic stanzas between jobs of different types.
- Run `nomad job validate` before submission.
When it happens
Trigger: Submitting a job where `periodic { enabled = true }` (or a cron/crons spec) is combined with type = "service" or type = "system". Also triggered when the default type is left unset/derived to something other than batch.
Common situations: Copying a periodic block from a batch job into a service job; forgetting `type = "batch"` when adding a cron schedule; converting a long-running service into a scheduled job without changing its type.
Related errors
- eval broker is enabled; eval broker must be paused to delete
- ErrConnectRequireOneNetwork
- ErrConnectInvalidNetworkMode
- service.port must be set for mesh gateway service
- non-default Consul cluster requires Nomad Enterprise
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/ead0f76c9a07381e.
Report an issue: GitHub.