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

The Don Lachlan ale-at-ale.org at unpopularminds.org
Sat Aug 27 17:34:21 EDT 2011


On Sat, Aug 27, 2011 at 05:01:53PM -0400, David Tomaschik wrote:
> On 08/27/2011 04:26 PM, The Don Lachlan wrote:
> > On Fri, Aug 26, 2011 at 02:25:40PM -0400, Geoffrey Myers wrote:
> >> Is it possible?
> > 0 0 8-14 * 6  /usr/bin/foo
> 
> Unfortunately, that would actually cause the command to be run on the
> 8th through the 14th, and on all Saturdays. Per crontab(5):
> Note: The day of a command's execution can be specified by two fields —
> day of month, and day of week. If both fields are restricted (i.e.,
> aren't *), the command will be run when either field matches the cur‐
> rent time. For example,

You're right. Hell.

0 0 8-14 * * [ "`date '+%w'`" -eq "6" ] && /usr/bin/foo

> As a pointer for everyone: most modern versions of cron support 3 letter
> codes for month & day of week. Particularly for day of week, make use of
> this -- in some parts of the world, the week starts on different days.
> Three letter codes (Mon, Tue, etc.) are unambiguous without reading the
> man page.

AFAIK, days of the week either run 0-6 (Su-Sa) or 1-7 (M-Su), so Sunday is
the only one that floats and is valid as either 0 or 7. Are there
distributions which change this schema?

-L


More information about the Ale mailing list