On 14-09-11 12:29, no-re...@cfengine.com wrote: > Forum: CFEngine Help > Subject: Re: inserting lines into crontab > Author: davidlee > Link to topic: https://cfengine.com/forum/read.php?3,23442,23466#msg-23466 > > Neil: Thanks for your second reply. What my team members would like is the > capability simply to maintain a centralised repository of crontab-like > snippet files. This has great merit from the simplicity standpoint. These > will get installed onto a variety of different machines with different > functions, so those snippets will somehow need integrating into each system's > own cron functions. And I have to say that I very much sympathise with this > viewpoint. > > I believe in cfengine! So I would fully envision using each machine's > cfengine to import (perhaps selectively) those snippet files and insert them > into that machines own cron functionality. But what we are trying to avoid > is having to write the cron entries deep in the murky depths of cfengine > syntax, when a file repository sitting alongside those cfengine files will be > just as clean, and a lot more comprehensible. (Contrast the visual shock of, > for example, Ryan's method with the elegance of a one-line file snippet > (three lines if you include possible start and end markers. ) > > I believe in cfengine! But that's not the same as thinking "because I have > this great hammer, therefore I have to coerce every single detail of every > single problem to look like a nail". Rather I'm thinking "because I have > this great Swiss-army penknife, I should use the right tools in the right > places". And for us, that would the simplicity of writing crontab-like file > snippets as files (unencumbered by the complexity and therefore error-dangers > of writing cfengine scripts for each line of each crontab), and asking > cfengine to promise to maintain those into the target systems. > > Mike's earlier suggestion of "/etc/cron.d" looks very good. I've just > written and tested the cfengine scripting to do this. It installs such > snippets and maintains changes to them. All under the control of cfengine. > > Ryan: Thanks for the idea. As discussed above, my team members (including > me!) reckon it is much cleaner (the KISS principle) to maintain file snippets > if reasonably possible. And i think the method I have outlined is fully > conformant with cfengine principles, isn't it? >
we use the /etc/cron.d setup and use this bundle maybe you find it useful ### # Install a cronjob in a Vixie cron environment # bundle agent sara_cronjob(name,command,user,mins,hours,day_of_month, month,day_of_week) { vars: any:: "vixie_cron_dir" string => "/etc/cron.d"; classes: "VIXIE_CRON" expression => isdir("$(vixie_cron_dir)"); files: VIXIE_CRON:: "$(vixie_cron_dir)/$(name)" comment => "Vixie cron: one command per file", create => "true", edit_defaults => empty, edit_line => append_if_no_line("$(mins) $(hours) $(day_of_month) $(month) $(day_of_week) $(user) $(command)"), perms => mo("644","root"), classes => if_repaired( cron_job_added ); reports: !VIXIE_CRON:: "No Vixie cron software installed"; cron_job_added:: "$(name) is installed in $(vixie_cron_dir)"; } Usage: "any" usebundle => sara_cronjob("cfexecd","/etc/cfengine3/check_cfexecd.sh","root","*/4","*","*","*","*"); -- ******************************************************************** * Bas van der Vlies e-mail: b...@sara.nl * * SARA - Academic Computing Services Amsterdam, The Netherlands * ******************************************************************** _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine