String format

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

Seconds Minutes Hours Days of months Months Years Timezone Offset Week days Milliseconds
Range 0..59 0..59 0..23 0..30 0..11 Any Int Any Int 0..6 0..999
Suffix - - - - - - o w ms
Optional
Full syntax support
Position 0 1 2 3 4 Any after months Any after months Any after months Any after months
Examples 0, */15, 30 0, */15, 30 0, */15, 22 0, */15, 30 0, */5, 11 0, */15, 30 60o (UTC+1) 0w, */2w, 4w 0ms, */150ms, 300ms

Example with almost same description:

/-------------------- (0-59) ············ Seconds
| /------------------ (0-59) ············ Minutes
| | /---------------- (0-23) ············ Hours
| | | /-------------- (0-30) ············ Days of months
| | | | /------------ (0-11) ············ Months
| | | | | /---------- (optional, any int) Year
| | | | | | /-------- (optional) ········ Timezone offset
| | | | | | |  /----- (optional, 0-6) ··· Week days
| | | | | | |  |  /-- (optional, 0-999) · Milliseconds (0 by default)
* * * * * * 0o *w 0ms

Years, timezone, week days and milliseconds are optional settings. Next snippets are equal:

*/15 * * * *
*/15 * * * * * // with year
*/15 * * * * * 0ms // with year and milliseconds

Supported syntax

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

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)

Examples


Revision #14
Created 24 July 2020 06:16:38 by InsanusMokrassar
Updated 15 June 2022 09:43:56 by InsanusMokrassar