zester
GuidesModules

cron.present

Ensures a crontab entry exists for a user with the specified schedule and command.

Parameters

ParameterTypeDefaultDescription
namestringstate IDLabel / comment for the cron entry
userstringrootUser whose crontab is managed
commandstringRequired. Command to run
minutestring*Minute field (0-59 or *)
hourstring*Hour field (0-23 or *)
daymonthstring*Day-of-month field (1-31 or *)
monthstring*Month field (1-12 or *)
dayweekstring*Day-of-week field (0-7 or *)
requirelistRequisite states

Example

backup-db:
  cron.present:
    - user: postgres
    - command: /usr/local/bin/pg_backup.sh
    - minute: "0"
    - hour: "3"
    - require:
      - pkg.installed:postgresql

Behaviour

  • Check: finds entry by command string, compares schedule fields.
  • Apply: adds or replaces the entry via crontab -u <user> -.
  • Revert: removes the entry.

On this page