Quick Guide
This guide explains cronx expression by comparing it with the conventional cron; if you are unfamiliar with cron, please read about cron first, or go to detail section directly.
More Expressive
Beyond all the time pattern a conventional cron support, cronx also support the following pattern:
day of year
week of month
span of time
fromstart time pattern
toend time pattern
All week date definition follows ISO standard, see details
In order to support these extra time patterns, cronx introduces the following main differences from the conventional cron:
- explicit indicator for calendar mode
- different order of unit
- new character set
..
for span of time
Let's go through them one by one.
Calendar Mode and Indicator
full # of units includes three clock units:
hour
,minute
,second
Token | Description | Calendar Combination | full # of units |
---|---|---|---|
d | day of year | year , day of year | 5 |
w | week of year | year , week of year , day of week | 6 |
m | special month composed by week | year , month , week of month , day of week | 7 |
c | common mode | year , month , day of month | 6 |
All indicator tokens should be at the end of an expression, and using ;
to seperate from the main expression.
Order of Unit
Generally, cronx takes a reverse order compared to cron, that is from bigger unit to smaller one
mode | Order |
---|---|
d | year day of year hour minute second |
w | year week of year day of week hour minute second |
m | year month week of month day of week hour minute second |
c | year month day of month hour minute second |
Span of Time
This is a new concept, it represents a span or a block of time from a start to an end expressed by cronx, start and end occur in pairs, and connected by new character set ..
in cronx.
cronx | meaning |
---|---|
* * * * 0..15; d | every minute (of every hour in every day in every year), from 0 second to 15 second |
* 10 1..5 8..10 .. 0; w | from 8:00:00 in 10th Monday to 10:59:00 in 10th Friday in every year |
* 10 1 5 8.. .. ..; m | first Friday in every October, from 8:00:00 to 23:59:59 |
* 10 * 8..10 .. ..; c | every day in every October, from 8:00:00 to 10:59:59 |
This pattern has several rules as following:
- At least one explicit
..
unit pattern should appear; - Only
..
or single number unit pattern should appear after a..
; - If a single number pattern
s
occurs after..
, it will be expanded tos..s
automatically in this context; - You can omit integer on each side of
..
, default are0
andL1
, respectively; i.e.,..
equals0..L1
or1..L1
;
L1 means the last one;
Unit Range and L
L is a useful indicator to represent ordinal in reverse order. Since correct pattern range is essential for correct and fast computation, explicity is much desired; It is highly recommended to use L indicator when you need to represent numbers close to end of a unit range, especially for calendar units that the range could vary on different circumstances;
Pattern with - /
When use forms like a-b/c
, you may encouter with a situation that b
does not comply with the sequence which a
and c
define; in this context, the last number a-b/c
represents is max(a+c*i)
where i > 0 and i is integer;
i.e. 1-9/5 represents 1, 6
Length, Omission, and Default
Second
and year
is not required, and to indicate year
, second
must be explicit first;
If U
is the full number of units for each mode (see table), U - 1
means year is implicit, U - 2
means year and second are implicit.
year
is always default to *
;
second
is default 0
in normal context, and 0..59
in span context;
For details and examples, please read detail section.