Cron Expression
A cron expression defines a schedule for running a scaling task at specific times.
This guide describes the Unix cron format (the standard 5-field syntax) with minute-level granularity. The schedule triggers when all fields match the current time. Cron schedules are evaluated in the timezone you selected.
Expression format and field values
A cron expression has five time and date fields separated by a blank.
* * * * *
│ │ │ │ └── day of week
│ │ │ └──── month
│ │ └────── day of month
│ └──────── hour
└────────── minute
Field | Valid Value Range | Notes |
|---|---|---|
| [0 - 59] | -- |
| [0 - 23] | 24-hour clock. If the |
| [1 - 31] | Not all months have 31 days. If you schedule |
| [1 -12] | -- |
| [0 - 6] |
|
Special characters and operators
These operators can be used in most fields:
Operator | Meaning | Example |
|---|---|---|
| any value |
|
| list of values |
|
| range of values |
|
| step values (every N units) Notes: You can also combine ranges with steps. |
|
Examples
This section provides some simple templates that you can directly use. If your suitable requires complex expressions that uses combination of operators, please refer to the examples here.
Simple templates
Use case | Cron expression | Meaning |
|---|---|---|
Every minute |
| Runs every minute |
Every 5 minutes |
| Runs every 5 minutes |
Every hour |
| Runs at the start of every hour |
Daily at 09:30 |
| Runs at 09:30 every day |
Weekdays at 09:00 |
| Runs 09:00 Mon–Fri |
Monthly on the 1st at 09:00 |
| Runs at 09:00 on the 1st of every month |
Every Sunday at 09:00 |
| Runs 09:00 every Sunday |
Twice daily |
| Runs at 09:00 and 21:00 daily |
Common scenarios
The following examples show how to write Unix cron expressions for scheduled scaling tasks based on typical workload patterns.
Example 1: Scale up during weekday peak hours, then scale down during weekday off-peak
To do this, create two schedules—one for peak hours and one for off-peak hours.
-
Peak hours:
* 9-18 * * 1-5Runs every minute from 09:00 to 18:59, Monday to Friday. -
Off-peak:
* 0-8,19-23 * * 1-5Runs every minute from 00:00 to 08:59 and 19:00 to 23:59, Monday to Friday.
Example 2: Weekend low-cost mode + Monday restore
To do this, create two schedules—one for the weekend and one to restore on Monday.
-
Weekend:
* * * * 0,6Runs every minute on Saturday and Sunday. -
Monday restore:
0 9 * * 1Runs at 09:00 every Monday.