Cookbooks
cron
documentation
Cron D

cron_d

Back to resource list

The cron_d custom resource can be used to manage files in /etc/cron.d. It supports the same interface as Chef's built-in cron resource:

Actions

  • :create
  • :create_if_missing
  • :delete

Properties

NameTypeDefaultDescription
cron_nameStringnilSet the name of the cron job. If this isn't specified we'll use the resource name
predefined_valueStringnilSchedule your cron job with one of the special predefined value instead of ** * pattern.
This corresponds to "@reboot", "@yearly", "@annually","@monthly", "@weekly", "@daily", "@midnight" or "@hourly".
minuteInteger, String'*'Schedule your cron job. These correspond exactly to their equivalents in the crontab file. All default to "*".
hourInteger, String'*'Schedule your cron job. These correspond exactly to their equivalents in the crontab file. All default to "*".
dayInteger, String'*'Schedule your cron job. These correspond exactly to their equivalents in the crontab file. All default to "*".
monthInteger, String'*'Schedule your cron job. These correspond exactly to their equivalents in the crontab file. All default to "*".
weekdayInteger, String'*'Schedule your cron job. These correspond exactly to their equivalents in the crontab file. All default to "*".
commandString'*'The command to run. Required for :create and :create_if_missing actions.
userString'root'The user to run as.
mailtoString'*'Set the corresponding environment variables in the cron.d file.
pathString'*'Set the corresponding environment variables in the cron.d file.
homeString'*'Set the corresponding environment variables in the cron.d file.
shellString'*'Set the corresponding environment variables in the cron.d file.
random_delayInteger'*'Set the corresponding environment variables in the cron.d file.
environmentHash{}Hash containing additional arbitrary environment variables under which the cron job will be run (similar to the shell LWRP)
commentString'*'A comment to place in the cron.d file.
modeString, Integer'0600'The octal mode of the generated crontab file.

Examples

cron_d 'daily-usage-report' do
  minute  0
  hour    23
  command '/srv/app/scripts/daily_report'
  user    'appuser'
end
cron_d 'Setup the daily usage cron job' do
  cron_name 'daily-usage-report'
  minute  0
  hour    23
  command '/srv/app/scripts/daily_report'
  user    'appuser'
end