Defined Type: cron::weekly

Defined in:
manifests/weekly.pp

Summary

This type creates a cron job via a file in /etc/cron.d

Overview

Examples:

create a weekly cron that runs on the 7th day at 4 am and 1 minute

cron::weekly { 'delete_old_temp_files':
  minute      => '1',
  hour        => '4',
  weekday     => '7',
  environment => [ 'MAILTO="admin@example.com"' ],
  command     => 'find /tmp -type f -ctime +7 -delete',
}

Parameters:

  • command (Optional[String[1]]) (defaults to: undef)

    The command to execute.

  • ensure (Cron::Job_ensure) (defaults to: 'present')

    The state to ensure this resource exists in. Can be absent, present.

  • minute (Cron::Minute) (defaults to: 0)

    The minute the cron job should fire on. Can be any valid cron.

  • hour (Cron::Hour) (defaults to: 0)

    The hour the cron job should fire on. Can be any valid cron hour value.

  • weekday (Cron::Weekday) (defaults to: 0)

    The day of the week the cron job should fire on. Can be any valid cron weekday value.

  • user (Cron::User) (defaults to: 'root')

    The user the cron job should be executed as.

  • mode (Stdlib::Filemode) (defaults to: '0600')

    The mode to set on the created job file.

  • environment (Cron::Environment) (defaults to: [])

    An array of environment variable settings.

  • description (Optional[String]) (defaults to: undef)

    Optional short description, which will be included in the cron job file.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'manifests/weekly.pp', line 20

define cron::weekly (
  Optional[String[1]] $command     = undef,
  Cron::Job_ensure    $ensure      = 'present',
  Cron::Minute        $minute      = 0,
  Cron::Hour          $hour        = 0,
  Cron::Weekday       $weekday     = 0,
  Cron::User          $user        = 'root',
  Stdlib::Filemode    $mode        = '0600',
  Cron::Environment   $environment = [],
  Optional[String]    $description = undef,
) {
  cron::job { $title:
    ensure      => $ensure,
    minute      => $minute,
    hour        => $hour,
    date        => '*',
    month       => '*',
    weekday     => $weekday,
    user        => $user,
    environment => $environment,
    mode        => $mode,
    command     => $command,
    description => $description,
  }
}