[ale] cron entry that runs the 2nd saturday of every month
Geoffrey Myers
lists at serioustechnology.com
Sat Aug 27 12:54:16 EDT 2011
David Tomaschik wrote:
> On 08/26/2011 03:38 PM, Geoffrey Myers wrote:
>> 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
>
> If you have cron run every Saturday, the %u is unnecessary. (You know
> it's Saturday.) Then just compare to the range [8-14]. No cal needed.
> (Might be what you're doing already.)
case $monthday in
8 | 9 | 10 | 11 | 12 | 13 | 14) echo it is the 2nd saturday ;;
esac
>
--
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
More information about the Ale
mailing list