Schedule
Source: core/schedule.gleam
The schedule module provides a shared cron expression parser with zero external dependencies. It lives in core/ so that both services/cron/ (the polling loop that executes scheduled jobs) and plugins/tools/cron/ (the chat-based cron management tool) can use it without cross-layer imports.
Types
CronJob--alias(human-readable name),schedule(parsedCronSchedule),job_type(eitherShellJob(command)orAgentJob(prompt))CronSchedule-- fiveFieldvalues:minute,hour,dom(day of month),month,dow(day of week)Field--Star(wildcard),Value(Int),Range(Int, Int),Step(Int)(e.g.,*/15),List(List(Field))(comma-separated values)CurrentTime--minute,hour,dom,month,dow(the time to check against)JobType--ShellJob(command)runs a shell command;AgentJob(prompt)sends a prompt to the agent
Key Functions
parse_schedule(expr)-- parses a 5-field cron expression string (e.g.,"0 9 * * 1-5") into aCronSchedule. ReturnsResult(CronSchedule, String).cron_matches(schedule, now)-- checks whether a parsedCronSchedulematches aCurrentTime. ReturnsBool.
The parser supports the standard cron field syntax: wildcards (*), exact values, ranges (1-5), steps (*/15), and comma-separated lists. Each of the 5 fields is parsed independently and combined into a single CronSchedule.
Usage
services/cron/loads enabled cron jobs from theCronStore, parses schedules, and pollscron_matches()each minute to decide which jobs to fire.plugins/tools/cron/usesparse_schedule()to validate user-provided cron expressions when creating or editing cron jobs via chat.
Related Pages
- Config -- Cron configuration loaded from TOML
- Behaviours --
CronStorebehaviour for persistence