github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/job-specification/periodic.mdx (about) 1 --- 2 layout: docs 3 page_title: periodic Stanza - Job Specification 4 sidebar_title: periodic 5 description: |- 6 The "periodic" stanza allows a job to run at fixed times, dates, or intervals. 7 The easiest way to think about the periodic scheduler is "Nomad cron" or 8 "distributed cron". 9 --- 10 11 # `periodic` Stanza 12 13 <Placement groups={['job', 'periodic']} /> 14 15 The `periodic` stanza allows a job to run at fixed times, dates, or intervals. 16 The easiest way to think about the periodic scheduler is "Nomad cron" or 17 "distributed cron". 18 19 ```hcl 20 job "docs" { 21 periodic { 22 cron = "*/15 * * * * *" 23 prohibit_overlap = true 24 } 25 } 26 ``` 27 28 The periodic expression by default evaluates in the **UTC timezone** to ensure 29 consistent evaluation when Nomad spans multiple time zones. 30 31 ## `periodic` Requirements 32 33 - The job's [scheduler type][batch-type] must be `batch`. 34 - A job can not be updated to be periodically. Thus, to transition an existing job to be periodic, you must first run `nomad stop -purge «job name»`. This is expected behavior and is to ensure that this change has been intentionally made by an operator. 35 36 ## `periodic` Parameters 37 38 - `cron` `(string: <required>)` - Specifies a cron expression configuring the 39 interval to launch the job. In addition to [cron-specific formats][cron], this 40 option also includes predefined expressions such as `@daily` or `@weekly`. 41 42 - `prohibit_overlap` `(bool: false)` - Specifies if this job should wait until 43 previous instances of this job have completed. This only applies to this job; 44 it does not prevent other periodic jobs from running at the same time. 45 46 - `time_zone` `(string: "UTC")` - Specifies the time zone to evaluate the next 47 launch interval against. [Daylight Saving Time][dst] affects scheduling, so 48 please ensure the [behavior below][dst] meets your needs. The time zone must 49 be parsable by Golang's 50 [LoadLocation](https://golang.org/pkg/time/#LoadLocation). 51 52 ## `periodic` Examples 53 54 The following examples only show the `periodic` stanzas. Remember that the 55 `periodic` stanza is only valid in the placements listed above. 56 57 ### Run Daily 58 59 This example shows running a periodic job daily: 60 61 ```hcl 62 periodic { 63 cron = "@daily" 64 } 65 ``` 66 67 ### Set Time Zone 68 69 This example shows setting a time zone for the periodic job to evaluate in: 70 71 ```hcl 72 periodic { 73 cron = "*/15 * * * * *" 74 time_zone = "America/New_York" 75 } 76 ``` 77 78 ## Daylight Saving Time 79 80 Though Nomad supports configuring `time_zone`, we strongly recommend that periodic 81 jobs are specified with respect to UTC `time_zone`. Only customize `time_zone` 82 when the following daylight saving time behavior is *desired:* 83 84 - When leaping forward, periodic jobs scheduled for the skipped hour (eg 2:30am 85 in `America/New_York`) will be *skipped* for that day (eg March 10th). 86 87 - When falling back, periodic jobs scheduled for the duplicated hour (eg 1:30am 88 in `America/New_York`) will be *run twice* for that day (eg November 3rd). 89 90 [batch-type]: /docs/job-specification/job#type 'Batch scheduler type' 91 [cron]: https://github.com/gorhill/cronexpr#implementation 'List of cron expressions' 92 [dst]: #daylight-saving-time