One of the main features of hcron is split+join combined with indexing. Using these we will set up a rotor event.
We need a mechanism that will drive the rotor. The most obvious is to use one of the hcron datetime variables. We will use
The event will select a text string based on the minute value. We could do this for each of the sixty minutes, but we'll just use the ones value of the minute and ignore the tens (e.g., 11-> 1, 23 -> 3). Each time the event fires, we'll send out an email.
WORDScontains our list of text strings; one for each rotor position
MINis the minute value (always 2-digits; leading 0 if necessary)
IDXis the ones minute value; the "?!" is used to split using an empty separator
WORDis the text string selected from
IDXas the index
- the event fires each minute
The subject lines of the emails received will look something like:
Instead of using the ones minute value as an index, we can use the tens minute value. The range would then be 0-5 (for 00, 10, 20, 30, 40, and 50). The event file would be modified with:
- keep only required strings in
WORDS; extra words will not be a problem, though
IDXis set to the tens minute value
Although, the example above is simple, it shows how time can be used as a rotor to select from a list of strings. Instead of sending out emails, the select value could have been a hostname, a username, a command, or a combination. In effect, this method provides a time-based round-robin selection mechanism.