cron
Generated by tinox doc
tinox.core.cron, bundled with the compiler and also available as a standalone tinox-central package.
Parse and match
import tinox.core.cron
import tinox.core.time
class Main
{
fnc main() -> Int32
{
// every day at 09:00
const expr: CronExpr = Cron::parse("0 9 * * *")
const now: Int64 = Time::now()
println("matches now: " + Cron::matches(expr, now).toString())
println("next run at: " + Cron::nextRun(expr).toString())
return 0
}
}
class Cron
* Five numeric fields: minute hour day-of-month month day-of-week. * Fields accept *, comma lists, inclusive ranges, and /positive-step * on * or a range (for example a wildcard step of 15, or 1-10/2). * Weekdays are 0-7, * Sunday is 0 or 7. Names, macros, seconds, L, W and # are rejected. * A bare * day field is unrestricted; otherwise day-of-month and * day-of-week use traditional cron OR semantics when both are restricted. * All timestamps are Unix milliseconds in UTC, 1970 through 9999; * matches() ignores seconds/milliseconds within the scheduled minute.
Methods
@Errorclass CronError
* Invalid cron expression or timestamp.
Fields
message | String |
class CronExpr
Validated by Cron::parse, or at evaluation when constructed directly.
Fields
minute | String | |
hour | String | |
dayOfMonth | String | |
month | String | |
dayOfWeek | String |
class CronJob
Fields
expr | CronExpr | |
callback | fnc() -> Nothing | |
lastRun | Int64 | Last attempted scheduled UTC minute boundary; -1 means never run. |
class CronScheduler
Fields
jobs | List<CronJob> | |
running | Bool |
Methods
class ScheduledJob
* State of one @Scheduled job (used by the generated runner; usable directly). * Times are Unix milliseconds in UTC -- the schedule is always evaluated in UTC, so there * are no daylight-saving gaps or repeats. A job runs on one thread: an occurrence never * overlaps itself, and minutes that pass while a run is still executing are skipped, not * replayed (misfire policy "skip"). The state is in memory only; a restart forgets * `lastMinute`; the first run after a restart is the next matching minute boundary, so a restart inside * a matching minute skips it and one right before a boundary may repeat nothing.
Fields
expr | CronExpr | |
lastMinute | Int64 | Last claimed UTC minute boundary (ms) |