Skip to main content

Quick Guide

info

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:

  1. day of year
  2. week of month
  3. span of time from start time pattern to end time pattern
info

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:

  1. explicit indicator for calendar mode
  2. different order of unit
  3. 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

TokenDescriptionCalendar Combinationfull # of units
dday of yearyear, day of year5
wweek of yearyear, week of year, day of week6
mspecial month composed by weekyear, month, week of month, day of week7
ccommon modeyear, month, day of month6
info

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

modeOrder
dyear day of year hour minute second
wyear week of year day of week hour minute second
myear month week of month day of week hour minute second
cyear 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.

cronxmeaning
* * * * 0..15; devery minute (of every hour in every day in every year), from 0 second to 15 second
* 10 1..5 8..10 .. 0; wfrom 8:00:00 in 10th Monday to 10:59:00 in 10th Friday in every year
* 10 1 5 8.. .. ..; mfirst Friday in every October, from 8:00:00 to 23:59:59
* 10 * 8..10 .. ..; cevery day in every October, from 8:00:00 to 10:59:59

This pattern has several rules as following:

  1. At least one explicit .. unit pattern should appear;
  2. Only .. or single number unit pattern should appear after a ..;
  3. If a single number pattern s occurs after .., it will be expanded to s..s automatically in this context;
  4. You can omit integer on each side of .., default are 0 and L1, respectively; i.e., .. equals 0..L1 or 1..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.