cron
Manages a single per-user crontab entry, identified by the declaration name and tagged with a marker comment so only that entry is owned. Idempotent: re-applying an unchanged declaration reports no change.
Category: Scheduled tasks
States
| State | Meaning |
|---|---|
present | The user’s crontab has an entry tagged with the declaration name, carrying the declared schedule and command. |
absent | The user’s crontab has no entry tagged with the declaration name; an existing tagged entry is removed. |
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
command | string | yes | The command line to run (single line). Required for state present; rejected for absent. |
schedule | string | yes | A five-field cron spec (*/5 * * * *) or an @-shortcut (@daily, @reboot, …). Required for state present; rejected for absent. |
user | string | Owner of the crontab to manage. Default: root. |
Examples
Run a nightly backup
cron:
nightly-backup:
state: present
command: /usr/bin/backup
schedule: "0 2 * * *"
user: rootPer-user job with an @-shortcut
cron:
app-cache-warm:
state: present
command: /opt/myapp/bin/warm-cache
schedule: "@hourly"
user: myappRemove a job
Only the entry tagged with this name is removed; other crontab lines are left alone.
cron:
old-cleanup:
state: absent
user: rootNotes
- Linux only; the module shells out to
crontab(1)and fails when that binary is absent. - Manages exactly the entry tagged
# keystone-cron: <name>; other crontab lines are never touched. commandandscheduleare required forpresentand rejected forabsent.schedulefield contents are not deeply validated — only field count and known@-shortcuts.- Out of scope (planned, #105): per-field schedule params,
/etc/cron.ddrop-ins, environment lines.