Cron Expressions
This topic describes the supported cron expressions that you can use to schedule automatic application update checks and automatic backups in the KOTS Admin Console.
For more information, see Configuring Automatic Updates and Schedule Automatic Backups in Creating and Scheduling Backups.
Syntax
<minute> <hour> <day-of-month> <month> <day-of-week>
Fields
The following table lists the required cron fields and supported values:
Required Field | Allowed Values | Allowed Special Characters |
---|---|---|
Minute | 0 through 59 | , - * |
Hour | 0 through 23 | , - * |
Day-of-month | 1 through 31 | , - * ? |
Month | 1 through 12 or JAN through DEC | , - * |
Day-of-week | 1 through 7 or SUN through SAT | , - * ? |
Special Characters
Replicated uses an external cron Go library. For more information about it's usage, see cron.
The following table describes the supported special characters:
Special Character | Description |
---|---|
Comma (,) | Specifies a list or multiple values, which can be consecutive or not. For example, 1,2,4 in the Day-of-week field signifies every Monday, Tuesday, and Thursday. |
Dash (-) | Specifies a contiguous range. For example, 4-6 in the Month field signifies April through June. |
Asterisk (*) | Specifies that all of the values for the field are used. For example, using * in the Month field means that all of the months are included in the schedule. |
Question mark (?) | Specifies that one or another value can be used. For example, enter 5 for Day-of-the-month and ? for Day-of-the-week to check for updates on the 5th day of the month, regardless of which day of the week it is. |
Predefined Schedules
You can use one of the following predefined schedule values instead of a cron expression:
Schedule Value | Description | Equivalent Cron Expression |
---|---|---|
@yearly (or @annually) | Runs once a year, at midnight on January 1. | 0 0 1 1 * |
@monthly | Runs once a month, at midnight on the first of the month. | 0 0 1 * * |
@weekly | Run once a week, at midnight on Saturday. | 0 0 * * 0 |
@daily (or @midnight) | Runs once a day, at midnight. | 0 0 * * * |
@hourly | Runs once an hour, at the beginning of the hour. | 0 * * * * |
@never | Disables the schedule completely. Only used by KOTS. This value can be useful when you are calling the API directly or are editing the KOTS configuration manually. | 0 * * * * |
@default | Selects the default schedule option (every 4 hours). Begins when the Admin Console starts up. This value can be useful when you are calling the API directly or are editing the KOTS configuration manually. | 0 * * * * |
Intervals
You can also schedule the job to operate at fixed intervals, starting at the time the job is added or when cron is run:
@every DURATION
Replace DURATION
with a string that is accepted by time.ParseDuration, with the exception of seconds. Seconds are not supported by KOTS. For more information about duration strings, see time.ParseDuration in the Go Time documentation.
As with standard cron expressions, the interval does not include the job runtime. For example, if a job is scheduled to run every 10 minutes, and the job takes 4 minutes to run, there are 6 minutes of idle time between each run.
Examples
The following examples show valid cron expressions to schedule checking for updates:
-
At 11:30 AM every day:
30 11 * * *
-
After 1 hour and 45 minutes, and then every interval following that:
@every 1h45m