howdy/jobs/cron

When a scheduled job runs, in cron’s five fields: minute, hour, day of the month, month and day of the week, all in UTC.

let assert Ok(nightly) = cron.parse("0 3 * * *")
let assert Ok(weekdays) = cron.parse("*/15 9-17 * * mon-fri")

Each field takes *, a number, a range such as 9-17, a step such as */15 or 0-30/10, or a list of those separated by commas. Months may be written jan to dec and days of the week sun to sat, where 0 and 7 are both Sunday. @hourly, @daily (or @midnight), @weekly, @monthly and @yearly (or @annually) stand for the usual schedules.

As in most crons, when both the day of the month and the day of the week are restricted, a day matching either one counts: 0 0 1 * mon runs on the first of each month and on every Monday.

Types

A parsed schedule.

pub opaque type Cron

Values

pub fn next(
  cron: Cron,
  after milliseconds: Int,
) -> Result(Int, Nil)

The first minute the schedule matches strictly after after, both in unix milliseconds. An Error only for a schedule that never comes round, which parse refuses.

pub fn parse(text: String) -> Result(Cron, String)

Read a schedule, or say what is wrong with it.

pub fn to_string(cron: Cron) -> String

The schedule as it was written.

✨ Search Document