[ale] cron entry that runs the 2nd saturday of every month

Lightner, Jeff JLightner at water.com
Fri Aug 26 18:04:35 EDT 2011


I don't understand how %d and %u let you figure out that it is the 2nd Saturday of the month.   You'd still have to do some calculation.

-----Original Message-----
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of Erik Mathis
Sent: Friday, August 26, 2011 4:47 PM
To: Atlanta Linux Enthusiasts
Subject: Re: [ale] cron entry that runs the 2nd saturday of every month

I ran into this same issue, and iirc cron uses a AND to compare dates.
I ended up running it every Monday and added a wrapper to the script
to decide if its the right day to do this function. If not, just exit.

-Erik-

On Fri, Aug 26, 2011 at 4:27 PM, Geoffrey Myers
<lists at serioustechnology.com> wrote:
> Lightner, Jeff wrote:
>> But the OP wanted 2nd Saturday only.  The +%u just tells you it is
>> Saturday - not which Saturday.
>
> I am the op.  Using the combination of the day of the week and the day
> of the month you can calculate whether its the 2nd Saturday of the month
> or not.
>
>>
>> I had tested for it being Saturday in my 2008 script but if the cron
>> job only runs on Saturday it isn't really necessary.   (My test was
>> to prevent someone from just moving the cron job without
>> understanding its purpose.)
>>
>> -----Original Message----- From: ale-bounces at ale.org
>> [mailto:ale-bounces at ale.org] On Behalf Of Geoffrey Myers Sent:
>> Friday, August 26, 2011 3:39 PM To: Atlanta Linux Enthusiasts
>> Subject: Re: [ale] cron entry that runs the 2nd saturday of every
>> month
>>
>> Lightner, Jeff wrote:
>>> When I had to do this back in 2008 on HP-UX I worked out a script
>>> that relied on the cal (calendar) command.
>>>
>>> The following command line will give you the 2nd Saturday of the
>>> month:
>>>
>>> cal |cut -c19-20 |grep '[0-9]'|head -2 |tail -1
>>>
>>> The following command will give you today's day of month: date +%d
>>
>> Doing something similar only relying on date alone:
>>
>> date +%d date +%u
>>
>>> You put your script to compare day of month with the output of the
>>> cal line and run the desired command if they match.   Then your
>>> cron entry runs EVERY Saturday and the script determines whether to
>>> run the commands you want based on whether it is the 2nd Saturday.
>>>
>>> There may be easier ways to do this on Linux but I figured I'd send
>>>  you this at least as a basis for thought.
>>>
>>>
>>>
>>>
>>>
>>> -----Original Message----- From: ale-bounces at ale.org
>>> [mailto:ale-bounces at ale.org] On Behalf Of Geoffrey Myers Sent:
>>> Friday, August 26, 2011 2:26 PM To: Atlanta Linux Enthusiasts
>>> Subject: [ale] cron entry that runs the 2nd saturday of every month
>>>
>>>
>>> Is it possible?
>>>
>>> -- Until later, Geoffrey
>>>
>>> "I predict future happiness for America if they can prevent the
>>> government from wasting the labors of the people under the pretense
>>>  of taking care of them." - Thomas Jefferson
>>> _______________________________________________ Ale mailing list
>>> Ale at ale.org http://mail.ale.org/mailman/listinfo/ale See JOBS,
>>> ANNOUNCE and SCHOOLS lists at http://mail.ale.org/mailman/listinfo
>>>
>>>
>>>
>>> Proud partner. Susan G. Komen for the Cure.
>>>
>>>
>>> Please consider our environment before printing this e-mail or
>>> attachments.
>>>
>>> ---------------------------------- CONFIDENTIALITY NOTICE: This
>>> e-mail may contain privileged or confidential information and is
>>> for the sole use of the intended recipient(s). If you are not the
>>> intended recipient, any disclosure, copying, distribution, or use
>>> of the contents of this information is prohibited and may be
>>> unlawful. If you have received this electronic transmission in
>>> error, please reply immediately to the sender that you have
>>> received the message in error, and delete it. Thank you.
>>> ----------------------------------
>>>
>>> _______________________________________________ Ale mailing list
>>> Ale at ale.org http://mail.ale.org/mailman/listinfo/ale See JOBS,
>>> ANNOUNCE and SCHOOLS lists at http://mail.ale.org/mailman/listinfo
>>
>>
>
>
> --
> Until later, Geoffrey
>
> "I predict future happiness for America if they can prevent
> the government from wasting the labors of the people under
> the pretense of taking care of them."
> - Thomas Jefferson
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>

_______________________________________________
Ale mailing list
Ale at ale.org
http://mail.ale.org/mailman/listinfo/ale
See JOBS, ANNOUNCE and SCHOOLS lists at
http://mail.ale.org/mailman/listinfo



More information about the Ale mailing list