Defined Type: cron::job

Defined in:
manifests/job.pp

Overview

Cron job defined type with a bit of magic dust sprinkled all over.

Examples:

Consider cron job declaration using built-in type

cron { 'my_job':
  minute => 0,
  hour   => 3,
}

This differs in that it manages all time values by default

cron::job { 'my_job':
  minute => 0,
  hour   => 3,
}

Simple cron job that runs every minute

cron::job { 'ping-host':
  command => '/usr/local/bin/my-host-pinger',
}

More advanced declaration

cron::job { 'my-backup':
  command => '/usr/local/bin/my-backup',
  hour    => [ 0, 12 ],
  minute  => '*/10';
}

Parameters:

  • command (Cron::Command)

    Command path to be executed

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

    The user who owns the cron job

  • minute (Cron::Minute) (defaults to: '*')

    Cron minute

  • hour (Cron::Hour) (defaults to: '*')

    Cron hour

  • monthday (Cron::Monthday) (defaults to: '*')

    Cron monthday

  • month (Cron::Month) (defaults to: '*')

    Cron month

  • weekday (Cron::Weekday) (defaults to: '*')

    Cron weekday



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'manifests/job.pp', line 34

define cron::job (
  Cron::Command  $command,
  Cron::User     $user     = 'root',
  Cron::Minute   $minute   = '*',
  Cron::Hour     $hour     = '*',
  Cron::Monthday $monthday = '*',
  Cron::Month    $month    = '*',
  Cron::Weekday  $weekday  = '*',
) {

  include cron

  cron { $title:
    ensure   => present,
    user     => $user,
    command  => $command,
    minute   => $minute,
    hour     => $hour,
    monthday => $monthday,
    month    => $month,
    weekday  => $weekday,
  }

}