{"record":{"id":"021cbd5b8f024020","repo":"hashicorp/nomad","slug":"cron-is-deprecated-and-may-be-removed-in-a-future","errorCode":null,"errorMessage":"cron is deprecated and may be removed in a future release. Use crons instead","messagePattern":"cron is deprecated and may be removed in a future release\\. Use crons instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"nomad/structs/structs.go","lineNumber":4987,"sourceCode":"\t\t\thasAutoPromote = hasAutoPromote || u.AutoPromote\n\n\t\t\t// Having no canaries implies auto-promotion since there are no canaries to promote.\n\t\t\tallAutoPromote = allAutoPromote && (u.Canary == 0 || u.AutoPromote)\n\t\t}\n\t}\n\n\t// check if we have services with no shutdown delay set\n\tmErr.Errors = append(mErr.Errors, j.generateServiceShutdownDelayWarnings()...)\n\n\t// Check AutoPromote, should be all or none\n\tif hasAutoPromote && !allAutoPromote {\n\t\terr := fmt.Errorf(\"auto_promote must be true for all groups to enable automatic promotion\")\n\t\tmErr.Errors = append(mErr.Errors, err)\n\t}\n\n\t// cron -> crons\n\tif j.Periodic != nil && j.Periodic.Spec != \"\" {\n\t\terr := fmt.Errorf(\"cron is deprecated and may be removed in a future release. Use crons instead\")\n\t\tmErr.Errors = append(mErr.Errors, err)\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n\n// LookupTaskGroup finds a task group by name\nfunc (j *Job) LookupTaskGroup(name string) *TaskGroup {\n\tif j == nil {\n\t\treturn nil\n\t}\n\tfor _, tg := range j.TaskGroups {\n\t\tif tg.Name == name {\n\t\t\treturn tg\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":4969,"sourceCodeEnd":5005,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L4969-L5005","documentation":"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.","triggerScenarios":"Submitting a job whose `periodic` block sets `cron = \"...\"` (single spec field) rather than `crons = [...]`. Detected via j.Periodic != nil && j.Periodic.Spec != \"\".","commonSituations":"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`.","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."],"exampleFix":"// before\nperiodic {\n  enabled = true\n  cron = \"0 * * * *\"\n}\n// after\nperiodic {\n  enabled = true\n  crons = [\"0 * * * *\"]\n}","handlingStrategy":"validation","validationCode":"if job.Periodic != nil && job.Periodic.Spec != \"\" {\n    return fmt.Errorf(\"use crons = [...] instead of deprecated cron field\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["nomad","deprecation","periodic-job","cron"],"backgroundTag":"deprecated-field-usage","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"}