cron icon indicating copy to clipboard operation
cron copied to clipboard

Wrong flag is set for weekly definition

Open nerg4l opened this issue 2 years ago • 4 comments

As far as I know @weekly means 0 0 * * 0

At the moment DOW_STAR flag is set for this definition, but it should be DOM_STAR (M instead of W).

https://github.com/vixie/cron/blob/3ce0c3acdf086a82638818635961c70cba2b6ba7/entry.c#L147-L158

I noticed the same "bug" in cronie-crond/cronie#52 a few years ago.

nerg4l avatar Oct 25 '23 09:10 nerg4l

please have a look at https://github.com/vixie/cron/pull/25

are the flags on the other @ macros all correct?

vixie avatar Jan 19 '24 13:01 vixie

0 0 1 1 * --> @yearly and @annually
Day of week star --> DOW_STAR

0 0 1 * * --> @monthly Day of week star --> DOW_STAR

0 0 * * 0 --> @weekly Day of month star --> DOM_STAR

0 0 * * * --> @daily and @midnight I don't know if DOW_STAR and/or DOM_STAR flags should be added or not

0 * * * * --> @hourly Hour star --> HR_STAR

Edit: I had to change the @xyz to formatted code. I accidentally referenced a bunch of GitHub users.

nerg4l avatar Jan 19 '24 14:01 nerg4l

<<I don't know if DOW_STAR and/or DOM_STAR flags should be added or not>>

right. i can see from the code which flags are currently set by which @ macros. the purpose is to remember, in the entry in memory, whether a wildcard was used for that time domain. this is to implement some of the odd semantics of posix cron where the meaning of some time domains depends on whether others were wildcarded or not. so your original report at top of thread may not have been a real bug, depending on whether we want @mumble to work exactly as if * had been specified for some time domain, or whether we want it to behave as though first-to-last (lowest value to highest value) had been specified, which would not trigger wildcard semantics in the interpretation of that entry in memory. so what i'm asking for here is not which flags are set by each @ macro, but rather, which ones ought to be set in order to avoid violations of the law of least astonishment.

vixie avatar Jan 21 '24 21:01 vixie

It took me while to understand your message. Unfortunately, English is not my main language.

First of all, you are correct. My original report is not a "real" bug. The current implementation handles it correctly.

I checked how a job is "found", and there are two cases regarding day-of-week and day-of-month handling.

  1. One of them has a star symbol and the other does not.
  2. Both or neither of them has the start symbol.

As long as, these apply, every rule is handled correctly. Also, when both of them are starts, it does not matter if || or && is used between because both of them is true.

https://github.com/vixie/cron/blob/3ce0c3acdf086a82638818635961c70cba2b6ba7/cron.c#L317-L319

nerg4l avatar Jan 24 '24 13:01 nerg4l