Defined Type: cron::daily

Defined in:
manifests/daily.pp

Summary

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

Overview

Examples:

create a daily cron job with custom PATH environment variable

cron::daily { 'mysql_backup':
  minute      => '1',
  hour        => '3',
  environment => [ 'PATH="/usr/sbin:/usr/bin:/sbin:/bin"' ],
  command     => 'mysqldump -u root my_db >/backups/my_db.sql',
}

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.

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

    An array of environment variable settings.

  • 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.

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

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



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

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