Cron jobs in Zig, either as a package libcron to add or use the croner cli through croner.json. i was missing this for a while, i attempted a version a year ago in golang, but zig is just better
libcron
- Five-field cron parsing with wildcards, lists, ranges, and steps
- In-process callbacks and direct child-process execution
- UTC, fixed-offset, and caller-provided TZif timezones
- Concurrent execution and cancellation through
std.Io - Clean child-process termination during scheduler shutdown
croner CLI
runs command jobs in the background on macOS and Linux:
croner setupcreates a starter configurationcroner startlaunches the daemoncroner start <id>resumes a paused jobcroner stop <id>pauses a job and cancels its active invocationcroner stopcleanly shuts down the daemon and running jobscroner listreports active, paused, and offline jobscroner reloadreconciles configuration changes by stable job IDcroner logsreads or follows the combined daemon log
croner.json
jobs are defined in JSON format:
{
"$schema": "https://xcaeser.github.io/croner/croner.schema.json",
"jobs": [
{
"id": "sync",
"schedule": "*/5 * * * *",
"action": {
"command": {
"argv": ["npm", "run", "sync"],
"cwd": ".",
"env": {
"MODE": "production"
}
}
},
"overlap": "skip"
}
]
}
Invalid schedules, duplicate IDs, unknown fields, malformed environment names, and empty commands are rejected before startup or reload.
Invalid reloads leave the running daemon unchanged.
The CLI schedules in UTC and supports command actions only.
Paused state is daemon-local.
Automatic file watching, retries, timeouts, output capture, and log rotation are not included in this release.
Built for Zig 0.17.0