splayclass() with custom interval width

29 views
Skip to first unread message

mike.w...@verticalsysadmin.com

unread,
Jul 19, 2016, 12:28:31 AM7/19/16
to help-cfengine
From https://docs.cfengine.com/lts/reference-functions-splayclass.html:

"...splayclass assumes that you are running CFEngine with the default schedule of "every 5 minutes". If you change the executor schedule control variable, you may prevent the splayclass from ever being defined...."

I'm running on a 15-minute interval.  I need to set a command to run on every server, once a day only, without bottlenecks.

"splayclass" would be perfect, but it doesn't allow for customizable intervals.

My other options are:

1. Write a customized "edit_lines" bundle to create a cron job with random hour and minute, only if the cron job (with any hour and minute) is not already defined.

2. Try to hack something together to use one of my 96 different possible runtime intervals in every 24 hour period, and divide up the servers into up to 96 different buckets to make a manual approach to "splayclass."

3. Something else I haven't thought of yet.

Has anyone else encountered this problem?  Is there any workaround I could use other than 1 or 2 above?

If not, has anyone had to write policy similar to the cron job edit lines bundle described above?

Thanks,
--Mike Weilgart

P.S.: If there is a ticket (bug report/feature request) relating to this, I'd love a link to it so I can watch and vote.

mike.w...@verticalsysadmin.com

unread,
Jul 19, 2016, 12:42:30 AM7/19/16
to help-cfengine
Found the ticket; voted for it:


Question above still stands.  :)

mike.w...@verticalsysadmin.com

unread,
Sep 22, 2017, 12:22:23 AM9/22/17
to help-cfengine
The circle closes.  Last year I ended up not needing to solve this after all, but recently I ran into another instance of this.  (I was surprised to see no one had commented on the bug report https://tracker.mender.io/browse/CFE-769 or this email thread since then, but oh well.)

I've completed the option (1) I described below.

I wrote a custom "edit_line" bundle called "install_cronjob()", which accepts two parameters: "time_option" and "command".  The "time_option" can be either daily, weekly or semiweekly.

If the command is already scheduled in the crontab (the file being edited) with SOME schedule, any schedule, nothing is done.

If the command isn't already scheduled, it is scheduled for a randomly chosen time with the frequency defined by "time_option."

I could handle "daily" and "weekly" with CFEngine native code (including randomint() calls), but for semiweekly I had to fire up Awk, so I handled the "daily" and "weekly" options in Awk also just for simplicity.  (The awk command only runs if the cronjob isn't already scheduled.)

Best,
--Mike Weilgart
Vertical Sysadmin, Inc.

--
Need training on CFEngine, git, or shell?  Email trai...@verticalsysadmin.com.
Reply all
Reply to author
Forward
0 new messages