Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how about week number? #66

Open
h0n3ym4k opened this issue Sep 21, 2020 · 7 comments
Open

how about week number? #66

h0n3ym4k opened this issue Sep 21, 2020 · 7 comments

Comments

@h0n3ym4k
Copy link

Hi guys,
just wondering if a new field "week number" (in a year scale?i.e. 52 max? or in a month scale?i.e. 5 max? how about February?) could be introduced to crontab? so that many people are asking various "week"-dependent questions would be somewhat easier to solve? e.g. 3rd Monday of every/alternate month...etc

@t8m
Copy link
Member

t8m commented Mar 17, 2021

The question is how to introduce that in a backwards compatible way.

@h0n3ym4k
Copy link
Author

is it possible to steal the weekday field?
Mon-Sun is weekday 0-52 is week num?

@t8m
Copy link
Member

t8m commented Jun 18, 2021

0-7 are valid day of a week numbers.

@h0n3ym4k
Copy link
Author

that's why has to steal it
0-7 only means week num and Mon-Sun as weekday spec
should be easy to adapt?
or any system that cannot represent using Mon-Sun?

@rptaylor
Copy link

rptaylor commented Oct 4, 2023

This would also provide a close-enough alternative for running tasks e.g. every 1st/2nd/3rd Wednesday of the month, which AFAICT is not possible with current cron features (except possibly with some weird tricks).

While I understand current cron syntax has gone largely unchanged for a long time and must retain compatibility, perhaps there could be a scheme that can also allow new features to be introduced:

  • always accept the "conventional" syntax that always works the same way
  • for people wanting to use new features, also allow named arguments (kind of like Python function arguments), something like this:
    minute=5 hour=2 day=* month=* weekday=Sun week=50 root echo hello

The fact that all the fields are logical ANDs except if both day of month and weekday are specified is a counterintuitive exception that can cause confusion (and makes it impossible to do Nth Wednesday of a month) so I would suggest that if a new field is added it should have the usual logical AND behaviour.

Aside from being able to support new features, this would also have the benefit of being more user-friendly and human-comprehensible. If each field is named, the intent is clear and unambiguous, so it would be possible to allow any order of fields and omission of fields ('*' by default), meaning you don't have to memorize or look up the syntax to know the meaning of each field. You could for example write:

  • hour=2 minute=5 root echo hi
  • month=1 day=1 root echo Happy New Year

@t8m
Copy link
Member

t8m commented Oct 5, 2023

@rptaylor Nice idea! That should be implementable in backwards compatible way.

Anybody wants to try this?

@t8m t8m added the help wanted label Oct 5, 2023
@rptaylor
Copy link

rptaylor commented Oct 5, 2023

I'm not a developer per se but I will enthusiastically thumbs up emoji to any implementation attempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants