Node:Building flexible time classes, Neste:Scheduling interval, Forrige:Splaying host times, Opp:Using cfengine as a front-end for cron
Each time cfengine is run, it reads the system clock and defines the following classes based on the time and date:
Yrxx::
Yr1997
, Yr2001
. This class is probably
not useful very often, but it might help you to turn on the new-year lights,
or shine up your systems for the new millenium!
Month::
January
, February
. These
classes could be used to determine when students have their summer vacation,
for instance, in order to perform extra tidying, or to specially maintain some
administrative policy for the duration of a conference.
Day::
Monday
, Sunday
.
Dayxx::
Day1
, the 21st Day21
etc.
Hrxx::
Hr00
...Hr23
.
Minxx::
Min0
... Min59
.
This is probably not useful alone, but these values may be combined
to define arbitrary intervals of time.
Minxx_xx::
Min0_5
, Min5_10
.. Min55_0
.
Time classes based on the precise minute at which cfengine started are
unlikely to be useful, since it is improbable that you will want to ask
cron to run cfengine every single minute of every day: there would be no
time for anything to complete before it was started again. Moreover,
many things could conspire to delay the precise time at which cfengine
were started. The real purpose in being able to detect the precise
start time is to define composite classes which refer to arbitrary
intervals of time. To do this, we use the group
or classes
action to create an alias for a group of time values.
Here are some creative examples:
classes: # synonym groups: LunchAndTeaBreaks = ( Hr12 Hr10 Hr15 ) NightShift = ( Hr22 Hr23 Hr00 Hr01 Hr02 Hr03 Hr04 Hr05 Hr06 ) ConferenceDays = ( Day26 Day27 Day29 Day30 ) QuarterHours = ( Min00 Min15 Min30 Min45 ) TimeSlices = ( Min01 Min02 Min03 Min33 Min34 Min35)
In these examples, the left hand sides of the assignments are
effectively the ORed result of the right hand side. This if any
classes in the parentheses are defined, the left hand side class
will become defined. This provides a flexible and readable way of
specifying intervals of time within a program, without having to
use |
and .
operators everywhere.