[comp.sources.d] First monday of the month

merlyn@iwarp.intel.com (Randal Schwartz) (10/14/90)

In article <8083@gollum.twg.com>, david@twg (David S. Herron) writes:
| In my most previous job I was working with a bunch of former IBM-ers
| in a financial reporting sort of environment.  One of the things they
| wanted, and was surprised that cron was unable to do this "cleanly",
| was to have a job run on (for instance):
| 
| 		the first monday of the month
| 
| The "nth monday of the month" class of specification would be a
| very good addition.

Arrgghhghgh!  This was hashed, rehashed, and overhashed in
comp.unix.wizards (back when there *was* one).

The answer is that an unbroken cron (one more or less derived from V7)
can do this easily with:

10 3 1-7 * 1 some-command some-parameter

(to launch at 3:10 on the first monday of the month).

However, later versions of cron are broken, because some stupid
f**king student or suit-and-tie type decided to *or* together the
day-of-week and day-of-month fields, rather than *and*ing them, in
which case there's no way to do it without having "some-command"
decide if it's the right time of the month.  (If he/she wanted to add
'or'-ing, it should have been through a separate syntax... not
breaking existing logic.)

I'd really like the moron that came up with this misfeature to step
forward and take his or her collective beating on the net.  High
hopes, though.  He/she probably doesn't even read the net, and lives
in some cave running System V (blech) UNIX on a 386 (blech) box when
he/she isn't running DOS (double blech).

(Sorry, it's been a bad night.  But it feels better now. :-)

Just another UNIX hacker since the V6 days,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/

david@twg.com (David S. Herron) (10/15/90)

In article <1990Oct14.065042.16216@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes:
>In article <8083@gollum.twg.com>, david@twg (David S. Herron) writes:
>| The "nth monday of the month" class of specification would be a
>| very good addition.
>
>Arrgghhghgh!  This was hashed, rehashed, and overhashed in
>comp.unix.wizards (back when there *was* one).

Ah .. it wasn't obvious that cron ever offered that ability.  In any
case I stopped reading unix-wizards many years ago because 1) I ran out
of time and 2) it stopped being interesting.

And it wouldn't have helped me with the problem I mentioned at AT&T
since it's one of those "broken" versions of Unix ...

>Just another UNIX hacker since the V6 days,

yeh.. me too..


-- 
<- David Herron, an MMDF & WIN/MHS guy, <david@twg.com>
<- Formerly: David Herron -- NonResident E-Mail Hack <david@ms.uky.edu>
<-
<- Remember:  On System V it's "tar xovf", not "tar xvf"!

irv@happym.wa.com (Irving [h] Wolfe) (10/15/90)

In <1990Oct14.065042.16216@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes:

>In article <8083@gollum.twg.com>, david@twg (David S. Herron) writes:

>| surprised that cron was unable to do this "cleanly",
>| was to have a job run on (for instance):
>| the first monday of the month

>The answer is that an unbroken cron (one more or less derived from V7)
>can do this easily with:
>10 3 1-7 * 1 some-command some-parameter

>However, later versions of cron are broken

Okay, sure, they're broken.  The current way isn't as smart as the older way
(and by the way [wink], thanks for the history lesson, Randal).  But it is
still easy enough to do by having the crontab line use the date command inside
an if.  It's "inelegant" and harder to read, but big deal, the general answer
does exist:

52 8 * * 1 if [ `date +\%d` -ge 21 -a `date +\%d` -le 27 ] ; then echo "Subject: green RECYCLE out Tuesday morn\n" | smail opmgr ofcasst >/dev/null ; fi
-- 
 Irving Wolfe    Happy Man Corp.   irv@happym.wa.com    206/463-9399 ext.101
 4410 SW Point Robinson Road,  Vashon Island, WA  98070-7399     fax ext.116
 SOLID VALUE, the investment letter for Benj. Graham's intelligent investors