Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Implementation diverges from classic crontab syntax for "first *-day of month" #107

@Gerrit-K

Description

@Gerrit-K

In #63 (comment) it was stated that

This library only supports the original contrab expression. [...] A first Tueday of a month can only occur on days 1-7, so you could use the 0 8 1-7 * Tue expression to effectively get 8 AM on first seven days of any month that's a Tuesday.

However, according to the crontab manpage:

Note: The day of a command's execution can be specified in the
following two fields — 'day of month', and 'day of week'. If
both fields are restricted (i.e., do not contain the "*"
character), the command will be run when either field matches the
current time. For example,
"30 4 1,15 * 5" would cause a command to be run at 4:30 am on the
1st and 15th of each month, plus every Friday.

Applied to the first example above, 0 8 1-7 * Tue, that would be "At 08:00 on every day-of-month from 1 through 7 and on Tuesday.", which is also confirmed by crontab.guru.

There's a detailed blog post about this and some funky way to work around it, but these workarounds produce exceptions in this library.

I don't think this is something that is easy to fix without breaking clients, and something that perhaps shouldn't be fixed, since it's more of a quirk in the original syntax. However, for me this was quite unexpected and I wasn't able to find much information about it, so I thought it might be worth pointing out, in case it should be included in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions