Hi
We use something like this to distribute cron jobs over a specified
time interval:
define cron::interval(
$ensure = present,
$start_hour = undef,
$length = '60', # interval length in minutes
$comment = undef,
$command = undef,
$user = 'root',
){
$minutes_from_start = fqdn_rand($length)
$minutes_remainder = $minutes_from_start % 60
$additional_hours = ( $minutes_from_start - $minutes_remainder ) / 60
# calculate the real values for the cronjob
$cron_hour = ( $start_hour + $additional_hours ) % 24
$cron_minute = $minutes_remainder
cron{$name:
ensure => $ensure,
command => $command,
user => $user,
hour => $cron_hour,
minute => $cron_minute,
}
}
# Use it like this to run puppet
cron::interval{'early_puppet_run':
start_hour => 5,
length => 120,
comment => 'run puppet early in the morning form 5 to 7',
command => '/opt/puppetlabs/bin/puppet agent --test --color false'
}
Regards
Andreas
On 03/20/2018 10:49 AM, Ren wrote:
> Hey everyone,
>
>
> I am looking the best way to implement overall puppet-agent
> (v4.9.2) to run only once per day during a specific time. ie:
> between 4 hours > 8 hours.
>
> what do you suggest? should I go with to implement a cron type or
> something using a funciton schedule?
>
> Do you have any examples?
>
> Thank you very much . -r
>
>
> -- You received this message because you are subscribed to the
> Google Groups "Puppet Users" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
> [email protected]
> <mailto:[email protected]>. To view this
> discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/334cb9f8-24d1-46a0-8307-9f0f3c489c59%40googlegroups.com
>
>
<https://groups.google.com/d/msgid/puppet-users/334cb9f8-24d1-46a0-8307-9f0f3c489c59%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/7bb85619-8644-f38b-0ff8-dcf3f2ac31bf%40puzzle.ch.
For more options, visit https://groups.google.com/d/optout.