Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.wizards Subject: Re: Cron - First Saturday of the month Message-ID: <7286@star.cs.vu.nl> Date: 10 Aug 90 17:26:39 GMT References: <19744@orstcs.CS.ORST.EDU> <1990Aug8.185745.16606@iwarp.intel.com> <1990Aug8.214539.1264@watserv1.waterloo.edu> <1990Aug9.001850.19494@iwarp.intel.com> <1990Aug10.040654.17334@watserv1.waterloo.edu> <1990Aug10.063819.5253@iwarp.intel.com> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Dept. of Computer Science, Amsterdam, The Netherlands Lines: 87 The manual (man 5 crontab on SunOS 4.0.3c): [...] Note: the specification of days may be made by two fields (day of the month and day of the week). If both are speci- fied as a list of elements, both are adhered to. For exam- ple, 0 0 1,15 * 1 would run a command on the first and fifteenth of each month, as well as on every Monday. To specify days by only one field, the other field should be set to *. For example, 0 0 * * 1 would run a command only on Mondays. [...] The code: int match(cp, loct) register char **cp; register struct tm *loct; { int cancel_ex = 0; *cp = cmp(*cp, loct->tm_min, &cancel_ex); *cp = cmp(*cp, loct->tm_hour, &cancel_ex); *cp = cmp(*cp, loct->tm_mday, &cancel_ex); *cp = cmp(*cp, loct->tm_mon, &cancel_ex); *cp = cmp(*cp, loct->tm_wday, &cancel_ex); return(!cancel_ex); } char * cmp(p, v, cancel_ex) char *p; int *cancel_ex; { register char *cp; cp = p; switch(*cp++) { case EXACT: if (*cp++ != v) (*cancel_ex)++; return(cp); case ANY: return(cp); case LIST: while(*cp != LIST) if(*cp++ == v) { while(*cp++ != LIST) ; return(cp); } (*cancel_ex)++; return(cp+1); case RANGE: if(cp[0] < cp[1]) { if(!(cp[0]<=v && cp[1]>=v)) (*cancel_ex)++; } else if(!(v>=cp[0] || v<=cp[1])) (*cancel_ex)++; return(cp+2); } if(cp[-1] != v) (*cancel_ex)++; return(cp); } The conclusion: the manual and the code contradict each other! The example 0 0 1,15 * 1 ...will run the job on each monday whose date is either the 1st or the 15th! It might be too late to fix the manual... (Grrrr!) -- "UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." (Doug Gwyn)