A cron expression specifies when and how often to run. It consists of six (or optionally seven) arguments, separated by spaces:
Arg#1: Second. An integer in the range 0-59.
Arg#2: Minute. An integer in the range 0-59.
Arg#3: Hour. An integer in the range 0-23.
Arg#4: Day-of-month. An integer in the range 1-31.
Arg#5: Month. Either an integer in the range 1-12, or a case-insensitive three-character string, from: {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec}.
Arg#6: Day-of-week. Either an integer in the range 1-7, or a case-insensitive three-character string, from: {Sun, Mon, Tue, Wed, Thu, Fri, Sat}.
Arg#7 (optional): Year. Either empty, or an integer in the range 1970-2099.
Be careful not to supply real numbers (such as 0.5) if an integer is required; doing so causes misparsing and misprocessing to occur, but does not issue an error. Although the “.” (period) character is not permitted, the following special characters are allowed:
* (asterisk): Can be used in any of the seven fields to signify “all values”. For example, “*” as the fourth argument means “every day.”
, (comma): Can be used in any of the seven fields to separate items in a discrete list. For example, “MON,THU” in the sixth field means “on Monday and Thursday”.
- (hyphen): Can be used in any of the seven fields to indicate minimum-maximum of a range. For example, “Nov-Feb” in the fifth field means “in November, December, January, and February”.
/ (slash): Can be used in any of the seven fields to specify increments. For example, “7/20” in the first field means “on seconds 7, 27, and 47”.
? (query): Can be used in field 4 or field 6 (but no other field, and not simultaneously) to avoid collision or ambiguity.
L can be used in field 4 or field 6 or both (but not in combination with lists or ranges) to specify “the last”. For example, “L” in the fourth field means “the last day of the month” and “1L” in the sixth field means “the last Sunday of the month”.
“0 0 12 * * ?” means “At noon every day”.
“0 30 21 ? * *” means “At 9:30pm every day”.
“0 0 2 ? * Mon-Fri” means “Weekdays at 2:00am”.
“0 10/30 1,22 L * ?” means “At 1:10 and 1:40am and 10:10 and 10:40pm the last day of every month”.