Documentation
PLEASE NOTE: This document applies to latest version and not to the latest stable release v2.21
Documentation for other releases can be found by using the version selector in the top right of any doc page.cron
Manage cron jobs and crontab entries.
Attributes
check_mode:
support: full
Parameters
| Parameter | Required | Type | Values | Description |
|---|---|---|---|---|
| name | true | string | Description of the crontab entry. | |
| job | string | The command to execute. Required if state=present. | ||
| state | string | absent present |
Whether the job should be present or absent. [default: "present"] |
|
| minute | string | Minute when the job should run (0-59, *, */2, etc). [default: "*"] |
||
| hour | string | Hour when the job should run (0-23, *, */2, etc). [default: "*"] |
||
| day | string | Day of the month the job should run (1-31, *, */2, etc). [default: "*"] |
||
| month | string | Month of the year the job should run (1-12, JAN-DEC, *, etc). [default: "*"] |
||
| weekday | string | Day of the week the job should run (0-6, SUN-SAT, *, etc). [default: "*"] |
||
| special_time | string | annually daily hourly monthly reboot weekly yearly |
Special time specification (hourly, daily, weekly, monthly, reboot, etc). Cannot be combined with minute, hour, day, month, weekday. | |
| disabled | boolean | If the job should be disabled (commented out) in the crontab. [default: false] |
||
| user | string | The specific user whose crontab should be modified. Defaults to current user. | ||
| cron_file | string | If specified, uses this file instead of an individual user’s crontab. Relative paths are interpreted with respect to /etc/cron.d. |
Examples
- cron:
name: daily-backup
minute: "0"
hour: "2"
job: /usr/local/bin/backup.sh
state: present
- cron:
name: weekly-cleanup
special_time: weekly
job: /usr/local/bin/cleanup.sh
- cron:
name: old-job
state: absent
- cron:
name: hourly-check
special_time: hourly
job: /usr/local/bin/check.sh
disabled: true