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

2/10 is perceived as valid #2

Open
tomsommer opened this issue Jul 31, 2020 · 4 comments
Open

2/10 is perceived as valid #2

tomsommer opened this issue Jul 31, 2020 · 4 comments
Assignees
Labels

Comments

@tomsommer
Copy link

tomsommer commented Jul 31, 2020

2/10 * * * * is perceived as valid, but it is not

@hollodotme
Copy link
Owner

hollodotme commented Aug 5, 2020

Hi @tomsommer, thanks for the issue.

Your expression literally means: "At every 10th minute from 2 through 59."
Or from a more technical perspective: for( i = 2, i <= 59, i = i+10 )

Why should it not be valid? Can you elaborate?

@tomsommer
Copy link
Author

tomsommer commented Aug 5, 2020

crontab: installing new crontab
"/tmp/crontab.wsvoz6":10: bad minute
errors in crontab file, can't install.

https://crontab.guru/#2/10_*_*_*_*
"Non standard! May not work with every cron."

@hollodotme
Copy link
Owner

OK, I see.

Looking at ...

... there is no hint, that this is invalid for crontab.

https://en.wikipedia.org/wiki/Cron#CRON_expression even states:

Slash (/)
In vixie-cron, slashes can be combined with ranges to specify step values.[4] For example, */5 in the minutes field indicates every 5 minutes (see note below about frequencies). It is shorthand for the more verbose POSIX form 5,10,15,20,25,30,35,40,45,50,55,00. POSIX does not define a use for slashes; its rationale (commenting on a BSD extension) notes that the definition is based on System V format but does not exclude the possibility of extensions.[3]

Note that frequencies in general cannot be expressed; only step values which evenly divide their range express accurate frequencies (for minutes and seconds, that's /2, /3, /4, /5, /6, /10, /12, /15, /20 and /30 because 60 is evenly divisible by those numbers; for hours, that's /2, /3, /4, /6, /8 and /12); all other possible "steps" and all other fields yield inconsistent "short" periods at the end of the time-unit before it "resets" to the next minute, second, or day; for example, entering */5 for the day field sometimes executes after 1, 2, or 3 days, depending on the month and leap year; this is because cron is stateless (it does not remember the time of the last execution nor count the difference between it and now, required for accurate frequency counting—instead, cron is a mere pattern-matcher).

I tested 2/10 * * * * echo "Hello" on my machine (MacOS with Vixie Cron) and was able to install the cron.

I also tested 2/10 * * * * echo "Hello" on my server (Debian Buster with Vixie Cron) and was NOT able to install the cron. (Same error message as you reported.)

The only thing that makes sense to me is to implement different validation rulesets which can be configured by the user. But this is quite some effort, I guess.

Any thoughts?

@hollodotme hollodotme self-assigned this Aug 5, 2020
@tomsommer
Copy link
Author

The only thing that makes sense to me is to implement different validation rulesets which can be configured by the user. But this is quite some effort, I guess.

That would be the best solution

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

No branches or pull requests

2 participants