Croner - powerful cron scheduling for Zig

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 setup creates a starter configuration
  • croner start launches the daemon
  • croner start <id> resumes a paused job
  • croner stop <id> pauses a job and cancels its active invocation
  • croner stop cleanly shuts down the daemon and running jobs
  • croner list reports active, paused, and offline jobs
  • croner reload reconciles configuration changes by stable job ID
  • croner logs reads 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

3 Likes