Timers can be set according to a calendar-based schedule, expressed using a syntax similar to the UNIX cron utility. Both programmatic and automatic timers can use calendar-based timer expressions. Table 16–1 shows the calendar-based timer attributes.
Table 16–1 Calendar-Based Timer Attributes
Attribute |
Description |
Allowable Values |
Default Value |
Examples |
---|---|---|---|---|
second |
One or more seconds within a minute |
0 to 59 |
0 |
second="30" |
minute |
One or more minutes within an hour |
0 to 59 |
0 |
minute="15" |
hour |
One or more hours within a day |
0 to 23 |
0 |
hour="13" |
dayOfWeek |
One or more days within a week |
0 to 7 (both 0 and 7 refer to Sunday) Sun, Mon, Tue, Wed, Thu, Fri, Sat |
* |
dayOfWeek="3" dayOfWeek="Mon" |
dayOfMonth |
One or more days within a month |
1 to 31 –7 to –1 (a negative number means the nth day or days before the end of the month) Last [1st, 2nd, 3rd, 4th, 5th, Last] [Sun, Mon, Tue, Wed, Thu, Fri, Sat] |
* |
dayOfMonth="15" dayOfMonth="–3" dayOfMonth="Last" dayOfMonth="2nd Fri" |
month |
One or more months within a year |
1 to 12 Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec |
* |
month="7" month="July" |
year |
A particular calendar year |
A four–digit calendar year |
* |
year="2010" |
You can specify multiple values in calendar expressions, as described in the following sections.
Setting an attribute to an asterisk symbol (*) represents all allowable values for the attribute.
The following expression represents every minute:
minute="*"
The following expression represents every day of the week:
dayOfWeek="*"
To specify two or more values for an attribute, use a comma (,) to separate the values. A range of values is allowed as part of a list. Wildcards and intervals, however, are not allowed.
Duplicates within a list are ignored.
The following expression sets the day of the week to Tuesday and Thursday:
dayOfWeek="Tue, Thu"
The following expression represents 4:00 a.m., every hour from 9:00 a.m. to 5:00 p.m. using a range, and 10:00 p.m.:
hour="4,9–17,22"
Use a dash character (–) to specify an inclusive range of values for an attribute. Members of a range cannot be wildcards, lists, or intervals. A range of the form x–x, is equivalent to the single-valued expression x. A range of the form x–y where x is greater than y is equivalent to the expression x–maximum value, minimum value–y. That is, the expression begins at x, rolls over to the beginning of the allowable values, and continues up to y.
The following expression represents 9:00 a.m. to 5:00 p.m.:
hour="9–17"
The following expression represents Friday through Monday:
dayOfWeek="5–1"
The following expression represents the twenty-fifth day of the month to the end of the month, and the beginning of the month to the fifth day of the month:
dayOfMonth="25–5"
It is equivalent to the following expression:
dayOfMonth="25–Last,1–5"
The forward slash (/) constrains an attribute to a starting point and an interval and is used to specify every N seconds, minutes, or hours within the minute, hour, or day. For an expression of the form x/y, x represents the starting point and y represents the interval. The wildcard character may be used in the x position of an interval and is equivalent to setting x to 0.
Intervals may be set only for second, minute, and hour attributes.
The following expression represents every 10 minutes within the hour:
minute="*/10"
It is equivalent to:
minute="0,10,20,30,40,50"
The following expression represents every 2 hours starting at noon:
hour="12/2"