Cron Expressions for a Function Timer Trigger
- @every format
The format is "@every N unit". N is a positive integer. unit can be ns, µs, ms, s, m, or h. An @every expression means to invoke a function every N time units, as shown in Table 1.
- Standard format
The format is "seconds minutes hours day-of-month month day-of-week". day-of-week is optional. The fields must be separated from each other using a space. Table 2 describes the fields in a standard cron expression.
Table 2 Parameter description Parameter
Mandatory
Value Range
Special Characters Allowed
CRON_TZ
No. If this parameter is not set, the region's time zone is used by default.
-
-
Seconds
Yes
0–59
, - * /
Minutes
Yes
0–59
, - * /
Hours
Yes
0–23
, - * /
Day-of-month
Yes
1–31
, - * ? /
Month
Yes
1–12 or Jan–Dec. The value is case-insensitive, as shown in Table 3.
, - * /
Day-of-week
No
0–6 or Sun–Sat. The value is case-insensitive, as shown in Table 4. 0 means Sunday.
, - * ? /
Table 3 Value description of the month field Month
Digit
Abbreviation
January
1
Jan
February
2
Feb
March
3
Mar
April
4
Apr
May
5
May
June
6
Jun
July
7
Jul
August
8
Aug
September
9
Sep
October
10
Oct
November
11
Nov
December
12
Dec
Table 4 Value description of the day-of-week field Day of Week
Digit
Abbreviation
Monday
1
Mon
Tuesday
2
Tue
Wednesday
3
Wed
Thursday
4
Thu
Friday
5
Fri
Saturday
6
Sat
Sunday
0
Sun
Table 5 describes the special characters that can be used in a cron expression.
Table 5 Special character description Special Character
Meaning
Description
*
Used to specify all values within a field.
* in the minutes field means every minute.
,
Used to specify multiple values, which can be discontinuous.
For example, "Jan,Apr,Jul,Oct" or "1,4,7,10" in the month field and "Sat,Sun" or "6,0" in the day-of-week field.
-
Used to specify a range.
For example, "0-3" in the minutes field.
?
Used to specify something in one of the two fields in which the character is allowed, but not the other.
You can specify something only in the day-of-month or day-of-week field. For example, if you want your function to be executed on a particular day (such as the 10th) of the month, but do not care what day of the week that is, then put "10" in the day-of-month field and "?" in the day-of-week field.
/
Used to specify increments. The character before the slash indicates when to start, and the one after the slash represents the increment.
For example, "1/3" in the minutes field means to trigger the function every 3 minutes starting from 00:01:00 of the hour.
Table 6 describes several example cron expressions.
Table 6 Example cron expressions Function Scheduling Example
Cron Expression (Beijing Time)
12:00 every day
CRON_TZ=Asia/Shanghai 0 0 12 * * *
12:30 every day
CRON_TZ=Asia/Shanghai 0 30 12 * * *
26th, 29th, and 33rd minutes of each hour
CRON_TZ=Asia/Shanghai 0 26,29,33 * * * *
12:30 from Monday to Friday
CRON_TZ=Asia/Shanghai 0 30 12 ? * MON-FRI
Every 5 minutes during 12:00 and 14:59 from Monday to Friday
CRON_TZ=Asia/Shanghai 0 0/5 12-14 ? * MON-FRI
12:00 every day from January to April
CRON_TZ=Asia/Shanghai 0 0 12 ? JAN,FEB,MAR,APR *
If no cron expression is set, the region's time zone is used by default. If your task will run in a specific time zone, use CRON_TZ to specify the time zone. For example, to trigger your function at 04:00 on the first day of each month (Beijing time), use CRON_TZ=Asia/Shanghai 0 0 4 1 * *. The time zone expression varies depending on the region.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.