Installing/Updating Cron entries using Puppet Cron Resource
Puppet comes with a builtin cron resource which installs and manages cron entries. More of this resource is available at
https://docs.puppetlabs.com/puppet/latest/reference/types/cron.html
A cron resource with some of its attributes are
An example of using cron resource is as follows:
Example 1:
https://docs.puppetlabs.com/puppet/latest/reference/types/cron.html
A cron resource with some of its attributes are
cron { 'resource title':
name => # The symbolic name of the cron job.
ensure => # The basic property that the resource should be...
command => # The command to execute in the cron job.
environment => # Any environment settings associated with this...
hour => # The hour at which to run the cron job. Optional;
minute => # The minute at which to run the cron job...
month => # The month of the year. Optional; if specified...
monthday => # The day of the month on which to run the...
provider => # The specific backend to use for this `cron...
special => # A special value such as 'reboot' or 'annually'...
target => # The name of the crontab file in which the cron...
user => # The user who owns the cron job. This user must...
weekday => # The weekday on which to run the command...
# ...plus any applicable metaparameters.
}
An example of using cron resource is as follows:
Example 1:
cron { 'logrotate':
command => '/usr/sbin/logrotate',
user => 'root',
hour => 2,
minute => 0,
}
This will create a cron entry as follows:
# id
uid=0(root) gid=0(root) groups=0(root)
# crontab -l
# HEADER: This file was autogenerated at Tue Mar 29 11:02:53 +0530 2016 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: logrotate
0 2 * * * /usr/sbin/logrotate
Example 2: node 'node2.example.com','node3.example.com'{
cron { 'logrotate':
command => '/usr/sbin/logrotate',
user => 'root',
hour => [2,4,6],
minute => '*/10',
}
}
This will create a cron entry for user root as follows :
*/10 2,4,6 * * * /usr/sbin/logrotate
Comments
Best Harrah's Casino 대구광역 출장안마 · Golden Nugget 이천 출장샵 Casino & Hotel · Harrah's 남양주 출장안마 Reno · Harrah's Reno Casino and 성남 출장샵 Hotel 논산 출장마사지 · Harrah's Reno