Cron expressions are comprised of 6 required fields and one optional field separated by white space. The fields respectively are described as follows:
Field Name |
|
Allowed Values |
|
Allowed Special Characters |
Seconds
|
|
0-59
|
|
, - * /
|
Minutes
|
|
0-59
|
|
, - * /
|
Hours
|
|
0-23
|
|
, - * /
|
Day-of-month
|
|
1-31
|
|
, - * ? / L W C
|
Month
|
|
1-12 or JAN-DEC
|
|
, - * /
|
Day-of-Week
|
|
1-7 or SUN-SAT
|
|
, - * ? / L #
|
Year (Optional)
|
|
empty, 1970-2099
|
|
, - * /
|
The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".
The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fileds, but not the other.
The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".
The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".
The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.
posted on 2007-03-01 10:43
Rudy 阅读(186)
评论(0) 编辑 收藏 所属分类:
Spring