String format

As in crontab util, this library have almost the same format of string:

/---------- Seconds
| /-------- Minutes
| | /------ Hours
| | | /---- Days of months
| | | | /-- Months
| | | | | / (Optional) Years
| | | | | |
* * * * * *

Years are optional setting. Next snippets are equal:

*/15 * * * * *

And

*/15 * * * *

Supported syntax

Currently the library support next syntax for date/time elements:

  • {int}-{int} - ranges
  • {int}/{int} - start/step
  • */{int} - every {int}
  • {int} - just at the time
  • {other_element},{other_element} - listing
  • F or f - first possible value
  • L or l - last possible value (last day of month, for example)

Ranges

Ranges are working like common rangeTo (or ..) in kotlin:

0-5 * * * *

In the example above scheduler will trigger every second from the beginning of the minute up to fifth second of minute.

Start/Step

Start/step is a little bit more complicated syntax. It means start from the first element, repeat triggering every second element. Examples:

5/15 * * * *

Means that each minute starting from fifth second it will repeat triggering every fifteenth second: 5, 20, 35, 50.

Every

Every is more simple syntax and could be explained as a shortcut for 0/{int}. Example:

*/15 * * * *

Means that each minute it will repeat triggering every fifteenth second: 0, 15, 30, 45.

Just at the time

The most simple syntax. It means, that scheduler will call triggering every time when element was reached:

15 * * * *

Means that each minute scheduler will call triggering at the fifteenth second.

Listing

All the previous elements can be combined with listing. Lets just see several examples:

0,10 * * * *

Will trigger every minute at the 0 and 10 seconds (see Just at the time)

0-5,10 * * * *

Will trigger every minute from 0 to 5 seconds and at the 10 seconds (see Ranges)