Scheduling a snapshot
To precisely control when to take a snapshot, you can create a snapshot schedule for specific namepsaces. When scheduling snapshot creation, you can create either a one-time event or use Unix cron expressions to create a recurring schedule. Cron expressions support three fields and are separated by white space.
cron(
Minutes
Hours
Day-of-month
Month
Day-of-week
Year
)
Fields | Values | Wildcards |
---|---|---|
Minutes |
0–59 |
, - * / |
Hours |
0–23 |
, - * / |
Day-of-month |
1–31 |
, - * ? / L W |
Month |
1–12 or JAN-DEC |
, - * / |
Day-of-week |
1–7 or SUN-SAT |
, - * ? L # |
Year |
1970–2199 |
, - * / |
Wildcards
-
The , (comma) wildcard includes additional values. In the
Day-of-week
field,MON,WED,FRI
would include Monday, Wednesday, and Friday. Total values are limited to 24 per field. -
The - (dash) wildcard specifies ranges. In the
Hour
field, 1–15 would include hours 1 through 15 of the specified day. -
The * (asterisk) wildcard includes all values in the field. In the
Hours
field, * would include every hour. -
The / (forward slash) wildcard specifies increments. In the
Hours
field, you could enter1/10
to specify every 10th hour, starting from the first hour of the day (for example, the 01:00, 11:00, and 21:00). -
The ? (question mark) wildcard specifies one or another. In the
Day-of-month
field you could enter 7, and if you didn't care what day of the week the seventh was, you could enter ? in the Day-of-week field. -
The L wildcard in the
Day-of-month
orDay-of-week
fields specifies the last day of the month or week. -
The W wildcard in the
Day-of-month
field specifies a weekday. In theDay-of-month
field,3W
specifies the day closest to the third weekday of the month. -
The # wildcard in the Day-of-week field specifies a certain instance of the specified day of the week within a month. For example, 3#2 would be the second Tuesday of the month: the 3 refers to Tuesday because it is the third day of each week, and the 2 refers to the second day of that type within the month.
Note
If you use a '#' character, you can define only one expression in the day-of-week field. For example, "3#1,6#3" is not valid because it is interpreted as two expressions.
Limits
-
You can't specify the
Day-of-month
andDay-of-week
fields in the same cron expression. If you specify a value in one of the fields, you must use a ? (question mark) in the other. -
Snapshot schedules don't support the following frequencies:
-
Snapshots scheduled more frequently than 1 per hour.
-
Snapshots scheduled less frequently than 1 per day (24 hours).
If you have overlapping schedules that result in scheduling snapshots within a 1 hour window, a validation error results.
-
The following table has some sample cron strings.
Minutes | Hours | Day of week | Meaning |
---|---|---|---|
0 |
14-20/1 |
TUE |
Every hour between 2pm and 8pm on Tuesday. |
0 |
21 |
MON-FRI |
Every night at 9pm Monday–Friday. |
30 |
0/6 |
SAT-SUN |
Every 6 hour increment on Saturday and Sunday starting at 30 minutes after midnight (00:30) that day. This results in a snapshot at [00:30, 06:30, 12:30, and 18:30] each day. |
30 |
12/4 |
* |
Every 4 hour increment starting at 12:30 each day. This resolves to [12:30, 16:30, 20:30]. |
The following example demonstrates how to create a schedule that runs in 2-hour increments starting at 15:15 each day.
cron(15 15/2 *)
Currently, you can only use the Amazon Redshift Serverless API or AWS CLI to create a snapshot schedule. For more information about those operations, see Using the AWS CLI and Amazon Redshift Serverless API.