cron

Collection: builtin

Full Name: parallax.builtin.cron

Aliases: ansible.builtin.cron, cron

Synopsis

Manage entries in a user’s crontab

Parameters

NameTypeRequiredDefaultDescription
namestringyesDescription of the crontab entry or the job name to manage
jobstringThe command to execute (required unless state=absent)
statestringpresentabsent or present: whether to ensure the cron job is absent or present
minutestring*Minute field for the cron job (0-59, *, */n)
hourstring*Hour field for the cron job (0-23, *, */n)
daystring*Day of month field for the cron job (1-31, *, */n)
monthstring*Month field for the cron job (1-12, *, */n)
weekdaystring*Weekday field for the cron job (0-7, *, */n)
special_timestringSpecial time specification Choices: annually, daily, hourly, monthly, reboot, weekly, yearly
userstringrootThe specific user whose crontab should be modified
cron_filestringWrite cron job to a specific file in /etc/cron.d
backupboolfalseCreate a backup of the crontab before making changes
disabledboolfalseDisable the cron job by commenting it out
envboolfalseIf true, manage environment variable assignments in crontab
insertafterstringIf specified, insert job after the matching line
insertbeforestringIf specified, insert job before the matching line
rebootboolfalseRun job at reboot (alias for special_time=reboot)

Example

- name: Run the nightly backup at 02:30
  cron:
    name: nightly backup
    job: /usr/local/bin/backup.sh
    minute: "30"
    hour: "2"
    user: root
    state: present