Okay, I'll see your classes and raise you a regexp for clarity!
classes:
January|March|May|July|August|October|December::
"Last_Saturday" and => { "Saturday", classmatch("Day(2[5-9]|3[01])") };
April|June|September|November::
"Last_Saturday" and => { "Saturday", classmatch("Day(2[4-9]|30)") };
February::
"Last_Saturday" and => { "Saturday", classmatch("Day2[2-9]") };
-Dan
> Why not simply using :
>
> classes:
> "Last_Saturday" expression =>
> "Saturday.((Day31|Day30|Day29|Day28|Day27|Day26|Day25)|(Day24.(April|June|Sep
> tember|November)|(Day23.Day22.February))";
>
> commands:
> Last_Saturday::
> "do something";
>
> It does not take into account leap year, but it should not fail until
> 2020, enough time to find a better solution...
>
> Nicolas
>
>
> Mark Burgess wrote:
> > I never recommend using pipes in cfengine. You can do classmatch, AND, OR
> > on the existing dates to accomplish the result.
> >
> > Perhaps first and last Mon-Sun are useful classes to build in.
> >
> > Matt Richards wrote:
> >
> >> okay, I got it. Kinda hacky with all the pipes:
> >>
> >> vars:
> >> "year" string => execresult("/usr/bin/date +%Y","noshell");
> >> "month" string => execresult("/usr/bin/date +%m","noshell");
> >> "last_day" string => execresult("/usr/bin/cal $(month) $(year) |
> >> awk '{print $7}' | grep -E "^[0-9]" | tail -1","useshell");
> >>
> >> classes:
> >> "Last_Saturday" expression => classify("Day$(last_day)");
> >>
> >> On Wed, Mar 3, 2010 at 8:26 AM, Matt Richards <[email protected]> wrote
> :
> >>
> >>> Interesting. I had something similar with how to schedule for the last
> >>> day of the month (ya, the shell commands are cheating a bit):
> >>>
> >>> vars:
> >>> "year" string => execresult("/usr/bin/date +%Y","noshell");
> >>> "month" string => execresult("/usr/bin/date +%m","noshell");
> >>> "last_day" string => execresult("/usr/bin/cal $(month) $(year) |
> >>> grep . | fmt -1 | tail -1","useshell");
> >>>
> >>> classes:
> >>> "End_Of_Month" expression => classify("Day$(last_day)");
> >>>
> >>> .
> >>> .
> >>> .
> >>>
> >>> End_of_Month.Hr23::
> >>>
> >>> So basically at 11:00pm on the last day of the month, it would fire
> >>> off. I am thinking something similar might be possible for the last
> >>> Saturday.
> >>>
> >>>
> >>> 2010/3/3 <[email protected]>:
> >>>
> >>>> Over at Ars there was a discussion about scheduling a cron job for the
> >>>> last Saturday of each month. Alas, cron cannot do this on its own. Wha
> t
> >>>> followed as a lot of short scripts to help but very few were portable.
> >>>>
> >>>> One of the newer goals of Cfengine is to be an enterprise scheduler. Fo
> r
> >>>> fun and reputation how would you use Cfengine to schedule a job on the
> >>>> last Saturday of each month?
> >>>>
> >>>> Sincerely,
> >>>> --
> >>>> Neil Watson
> >>>> 416-673-3465
> >>>>
> >>>>
> >>>>
> >>>> CONFIDENTIALITY WARNING
> >>>> This communication, including any attachments, is for the exclusive use
> of addressee and may contain proprietary and/or confidential information. If
> you are not the intended recipient, any use, copying, disclosure, disseminati
> on or distribution is strictly prohibited. If you are not the intended recipi
> ent, please notify the sender immediately by return e-mail, delete this commu
> nication and destroy all copies.
> >>>>
> >>>> AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ
> >>>> Ce message, ainsi que les pièces qui y sont jointes, est destiné à
> >>>> lusage e
> xclusif de la personne à laquelle il sadresse et peut contenir de
> linformation
> personnelle ou confidentielle. Si le lecteur de ce message nen est pas le de
> stinataire, nous lavisons par la présente que toute diffusion, distribution,
> r
> eproduction ou utilisation de son contenu est strictement interdite. Veuillez
> avertir sur-le-champ lexpéditeur par retour de courrier électronique et
> suppri
> mez ce message ainsi que toutes les pièces jointes.
> >>>>
> >>>> _______________________________________________
> >>>> Help-cfengine mailing list
> >>>> [email protected]
> >>>> https://cfengine.org/mailman/listinfo/help-cfengine
> >>>>
> >>>>
> >>>>
> >> _______________________________________________
> >> Help-cfengine mailing list
> >> [email protected]
> >> https://cfengine.org/mailman/listinfo/help-cfengine
> >>
> >
> >
>
> _______________________________________________
> Help-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/help-cfengine
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine