API Reference

Lightweight cron parsing & scheduling for Julia. Crontab.jl provides a small, fast cron expression parser and runtime helpers to compute next/previous execution times, generate upcoming timestamps, and block until the next trigger.

Types

Crontab.CronType
Cron

Internal representation of a cron schedule. Construct a cron schedule from a five-field expression: minute hour day month weekday. Supports *, /, -, ,, and . where . denotes an empty set.

Examples

julia> Cron("*/15 * * * *")
"At every 15th minute"

julia> Cron("*", "*", "*", "*", "1")
"At every minute
on Monday"

julia> Cron(minute="0", hour="0", day="1")
"At minute 0
past hour 0
on day-of-month 1"
source

Functions

Crontab.nextFunction
next(c::Cron, dt::DateTime) -> DateTime

Return the next DateTime on a minute boundary that satisfies the cron schedule c, starting from dt (inclusive).

Note

The day-of-month and day-of-week fields are combined with OR semantics, unless one of them is *, in which case only the other is considered.

Examples

julia> using Dates

julia> next(Cron("*/5 * * * *"), DateTime("2025-01-01T12:03:00"))
2025-01-01T12:05:00

julia> next(Cron("0 14 * * *"), Date(2025,01,01))
2025-01-01T14:00:00
source
Crontab.prevFunction
prev(c::Cron, dt::DateTime) -> DateTime

Return the greatest DateTime on a minute boundary that satisfies the cron schedule c, before dt (inclusive).

Examples

julia> using Dates

julia> prev(Cron("*/5 * * * *"), DateTime("2025-01-01T12:03:00"))
2025-01-01T12:00:00

julia> prev(Cron("0 * 23 * *"), Date(2025,01,01))
2024-12-23T23:00:00
source
Crontab.timestepsFunction
timesteps(c::Cron, start::DateTime, n::Integer) -> Vector{DateTime}

Return n upcoming chrono-based times for cron schedule c, strictly after start.

Examples

julia> using Dates

julia> timesteps(Cron("*/15 * * * *"), DateTime("2025-01-01T12:03:00"), 4)
4-element Vector{DateTime}:
 2025-01-01T12:15:00
 2025-01-01T12:30:00
 2025-01-01T12:45:00
 2025-01-01T13:00:00

julia> timesteps(Cron("*/5 * * * *"), Date(2025,01,01), 2)
2-element Vector{DateTime}:
 2025-01-01T00:05:00
 2025-01-01T00:10:00
source
Crontab.prettyFunction
pretty(c::Cron) -> String

Returns a human-readable representation of a Cron schedule. Used internally when printing a Cron.

Examples

julia> pretty(Cron("*/15 * * * *"))
"At every 15th minute"

julia> pretty(Cron("0 14 * * 1-5"))
"At minute 0\npast hour 14\non every day-of-week from Monday through Friday"
source