Comments (7)
I believe that is due to my reading of https://en.wikipedia.org/wiki/Cron:
While normally the job is executed when the time/date specification fields all match the current time and date, there is one exception: if both "day of month" (field 3) and "day of week" (field 5) are restricted (not "*"), then one or both must match the current day.[3]
from cron.
Wouldn't that mean strictly *
, not */10
? With *
meaning all and Dom and Dow being an OR, *
being a special case makes sense since you can't use a value outside the range.
I'm wondering whether starBit should be set in the case of */10
since it really does't mean all.
from cron.
Yeah, I agree
from cron.
@robfig when I remove starBit when step > 1 the following test fails:
spec_test.go:164: Mon Jul 9 23:35 2012, "0 0 0 */5 Apr,Aug,Oct Mon": (expected) 2012-08-06 00:00:00 +0000 UTC != 2012-08-01 00:00:00 +0000 UTC (actual)
Just want to make sure I'm not missing something here. Since Dom and Dow is an OR, it actually should be 2012-08-01 00:00:00 +0000 UTC
right?
Changes made:
diff --git a/parser.go b/parser.go
index 01c4c3a..40b824b 100644
--- a/parser.go
+++ b/parser.go
@@ -225,6 +225,10 @@ func getRange(expr string, r bounds) (uint64, error) {
if singleDigit {
end = r.max
}
+
+ if step > 1 {
+ extra_star = 0
+ }
default:
return 0, fmt.Errorf("Too many slashes: %s", expr)
}
from cron.
I imagine the test is wrong in that case
from cron.
This is fixed on v3 branch.
from cron.
Fwiw, I think that the old behavior may have been correct here? The Wikipedia page looks to have been updated to match the man page:
Wikipedia:
While normally the job is executed when the time/date specification fields all match the current time and date, there is one exception: if both "day of month" (field 3) and "day of week" (field 5) are restricted (not contain "*"), then one or both must match the current day.[7]
man page:
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.
Meaning */10
, which does contain a star, should be parsed as 'unrestricted', leading to the AND behavior not the OR behavior.
Came here after looking for a way to implement the behavior outlined in this blog post and wondering if this library implemented the AND or the OR.
It's pretty esoteric behavior but I figured I'd point it out since I noticed.
from cron.
Related Issues (20)
- When creating a new cron object, multiple construction methods are provided.
- provide ant way to change the value of Now for testing purposes HOT 1
- I cannot pass second as 6th param for cronjob HOT 2
- Troubles in docker
- crontab run error HOT 2
- [discuss] Discussion of executing a single server under multiple nodes HOT 3
- does this package support standard crontab expr HOT 1
- Why is time zone not supported? this is exactly what i need HOT 1
- cron.New().Remove() HOT 1
- performance wise question
- During the execution process of scheduled tasks, a change in the system time can result in incorrect execution timing. HOT 2
- Tag 3.0.1 too old HOT 1
- How to start job from the past time?
- How to retrieve command
- Wrong Result on Sync Cron HOT 1
- Removing entry does not update the cron HOT 1
- cron expression failed to be parsed - unknown unit "d"
- How to schedule job to run on every 2nd thursday of month at 10:10 AM HOT 1
- Data Loss When Program Stops Running
- os time change HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cron.