{"record":{"id":"ead0f76c9a07381e","repo":"hashicorp/nomad","slug":"periodic-can-only-be-used-with-q-or-q-scheduler","errorCode":null,"errorMessage":"Periodic can only be used with %q or %q scheduler","messagePattern":"Periodic can only be used with %q or %q scheduler","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":4857,"sourceCode":"\t\tif j.Type == \"system\" && tg.Count > 1 {\n\t\t\tmErr.Errors = append(mErr.Errors,\n\t\t\t\tfmt.Errorf(\"Job task group %s has count %d. Count cannot exceed 1 with system scheduler\",\n\t\t\t\t\ttg.Name, tg.Count))\n\t\t}\n\t}\n\n\t// Validate the task group\n\tfor _, tg := range j.TaskGroups {\n\t\tif err := tg.Validate(j); err != nil {\n\t\t\touter := fmt.Errorf(\"Task group %s validation failed: %v\", tg.Name, err)\n\t\t\tmErr.Errors = append(mErr.Errors, outer)\n\t\t}\n\t}\n\n\t// Validate periodic is only used with batch or sysbatch jobs.\n\tif j.IsPeriodic() && j.Periodic.Enabled {\n\t\tif j.Type != JobTypeBatch && j.Type != JobTypeSysBatch {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\n\t\t\t\t\"Periodic can only be used with %q or %q scheduler\", JobTypeBatch, JobTypeSysBatch,\n\t\t\t))\n\t\t}\n\n\t\tif err := j.Periodic.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t}\n\t}\n\n\tif j.IsParameterized() {\n\t\tif j.Type != JobTypeBatch && j.Type != JobTypeSysBatch {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\n\t\t\t\t\"Parameterized job can only be used with %q or %q scheduler\", JobTypeBatch, JobTypeSysBatch,\n\t\t\t))\n\t\t}\n\n\t\tif err := j.ParameterizedJob.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, err)","sourceCodeStart":4839,"sourceCodeEnd":4875,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L4839-L4875","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\njob \"backup\" {\n  type = \"service\"\n  periodic { enabled = true; crons = [\"0 * * * *\"] }\n}\n// after\njob \"backup\" {\n  type = \"batch\"\n  periodic { enabled = true; crons = [\"0 * * * *\"] }\n}","handlingStrategy":"validation","validationCode":"if job.IsPeriodic() && job.Periodic.Enabled &&\n   job.Type != \"batch\" && job.Type != \"sysbatch\" {\n    return fmt.Errorf(\"periodic job must be type batch or sysbatch, got %q\", job.Type)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set `type = \"batch\"` whenever adding a periodic block.","Never copy periodic stanzas between jobs of different types.","Run `nomad job validate` before submission."],"tags":["nomad","periodic-job","scheduler","job-validation"],"backgroundTag":"invalid-job-scheduler-type","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}