Save yourself two shell commands - if you invoke cal with no arguments, it
gives you this month's calendar.  So skip the first two calls to date :-)

-Dan

> 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 <defraya...@gmail.com> 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  <nwat...@symcor.com>:
> >> 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.  What
> >> 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.  For
> >> 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 yo
> u are not the intended recipient, any use, copying, disclosure, dissemination
>  or distribution is strictly prohibited. If you are not the intended recipien
> t, please notify the sender immediately by return e-mail, delete this communi
> cation and destroy all copies.
> >>
> >> AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ
> >> Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
> >> exc
> lusif de la personne à laquelle il s’adresse et peut contenir de 
> l’information p
> ersonnelle ou confidentielle. Si le lecteur de ce message n’en est pas le dest
> inataire, nous l’avisons par la présente que toute diffusion, distribution, 
> rep
> roduction ou utilisation de son contenu est strictement interdite. Veuillez a
> vertir sur-le-champ l’expéditeur par retour de courrier électronique et 
> supprime
> z ce message ainsi que toutes les pièces jointes.
> >>
> >> _______________________________________________
> >> Help-cfengine mailing list
> >> Help-cfengine@cfengine.org
> >> https://cfengine.org/mailman/listinfo/help-cfengine
> >>
> >>
> >
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to