[Techtalk] Age-old cron problem
Nicoya Helm
nicoya at nicoya.org
Mon Dec 10 17:20:49 UTC 2007
> -------- Original Message --------
> Subject: Re: [Techtalk] Age-old cron problem
> From: Conor Daly <c.daly at met.ie>
> Date: Mon, December 10, 2007 10:33 am
> To: techtalk at linuxchix.org
>
>
> On Mon, Dec 10, 2007 at 06:54:44AM -0700 or thereabouts, Nicoya Helm wrote:
> >
> > I think I will try this approach: via script, write a date to a file
> > somewhere on the starting Sunday as a reference for a counter. In that
> > same script, put in logic to increment the date counter by one (i.e.
> > day) then test to see if we have reached the max (14 days). If we have,
> > run the required Every-Other-Sunday-action, then reset counter. Rinse
> > and repeat. This will still require a manual kick-off on the first
> > Sunday, but after that should run every 14 days, i.e. every other
> > Sunday.
>
> You might consider 'date +"%U"' which gives a week (in the year) number.
> You could then test if the week number is odd or even and trigger on that.
> That avoids the possibility that a day could be missed pushing your script
> out to run on a Monday instead of Sunday...
>
> Conor
> --
>
I stumbled across a similar suggestion shortly after sending my last
email. Not sure how I missed it in my first searches, but it works well
- wish I'd thought of it myself :). Here's what I tested (found at
http://sysunconfig.net/aixtips/cron_trick.txt)
____________________
WK=`date +%W`
ON_WK=`expr $WK % 2`
# to test for and execute on odd week, uncomment the =1 line
# to test for and execute on even week, uncomment the =0 line
#if [ $ON_WK = 1 ]
if [ $ON_WK = 0 ]
then
echo $BODY |mailx -s "test email" user at email.com
fi
____________________
~~~Nicoya...
---KC0VVR---
"It is never too late to be what you might have been." --George Eliot
More information about the Techtalk
mailing list