Cron - First Saturday of the month

Randal Schwartz merlyn at iwarp.intel.com
Fri Aug 10 16:38:19 AEST 1990


In article <1990Aug10.040654.17334 at watserv1.waterloo.edu>, dmcanzi at watserv1 (David Canzi) writes:
| In the absence of source code, you experiment.  At 23:32 on Thursday,
| Aug 9, these were the contents of my crontab:
| 
| 32 23 1-5 * 1 date > /u/dmcanzi/temp/www
| 32 23 7-11 * 4 date > /u/dmcanzi/temp/xxx
| 32 23 1-5 * 4 date > /u/dmcanzi/temp/yyy
| 32 23 7-11 * 1 date > /u/dmcanzi/temp/zzz
| 
| The files xxx, yyy, and zzz were created, www was not created.  The
| manual page is correct.

See, but now that makes cron non-orthogonal.  Yuck.  So, without
looking at the source, I have to second-guess the logic.  Is it:

minutes-match AND hours-match AND (days-match OR dow-match) AND months-match
(meaning 0 0 1 7 1 would run on the first of June and all Mondays in June)

or:

minutes-match AND hours-match AND ((days-match AND months-match) OR dow-match)
(meaning 0 0 1 7 1 would run on the first of June and all Mondays in any month)

or:

some-other-combination-that-I-didn't-type-in

Either way, throwing that OR in there means the manpage is incomplete.
(And cron is hard to inuitively guess now.)  Putting it another way, I
could not work from the manpage and build a cron that is guaranteed to
work the same way as out-of-the-box cron.  Don't have a POSIX spec in
front of me.  What do they say about this ambiguity?

By the way, cron logic like this is backwards.  You can always get OR
logic by duplicating the entries.  To get AND logic, you have to have
something *in* the command make an additional decision.

And, continuing on with my tirade, since it says earlier in the
manpage "if a field is an asterisk character (*) it means that the job
is done for all possible values of the field", that would make me
believe that:

   0 0 * * 1

would work the same as:

   0 0 1-31 * 1

which is not true.  (The first executes 4 times a month, the second 31
times a month [more or less]).  This (now incorrect) intuition follows
from noticing that:

   * 0 * * *

is the same as:

   0-59 0 * * *

So, they really mucked up when they OR-ed in that day-of-week field.

Sigh.  Sorry.  I'll crawl under my rock now.  Cron's only for the
heavyweights, anyway.

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



More information about the Comp.unix.wizards mailing list