Comments (6)
I have also tried an alternative cron expression 0 0 ? * TUE#2
However gocrond returns a syntax error:
{"command":"/files/job_1.sh","crontab":"/etc/crontabs/job_1","level":"error","msg":"cronjob failed adding: failed to parse int from TUE#2: strconv.Atoi: parsing \"TUE#2\": invalid syntax","shell":"sh","spec":"0 0 ? * TUE#2","time":"2023-07-05T09:02:04+12:00","user":"root"}
from go-crond.
Looks like the 8-14 day of month range is ignored, and the job runs every Tuesday. I also double chcked the date and time on the container, and it's correct. Any ideas?
From crontab(5):
Commands are executed by cron(8) when the minute, hour, and month of year fields match the current time, and when at least one of the two day fields (day of month, or day of week) match the current time.
So that means commands are executed if either of the third (day of month) or fifth (day of week) fields match.
In your case, the command will run at midnight every day between the 8th and 14th (inclusive) of every month, and on every Tuesday.
Edit: Sorry, forgot to mention you can achieve "the second Tuesday of every month" like this:
0 0 8-14 * * [ $(date +\%u) = 2 ] && /files/job_1.sh
from go-crond.
@smlx Sounds like you are right, and that first cron expression is incorrect.
For now I worked around it by using a ‘test’ command before running job_1. It checks whether its Tuesday and cron expression runs the job between 8th and 14th.
Expressions like ‘TUE#2’ still aren’t supported though, which are a part of a cron spec. Might be a useful feature to add.
from go-crond.
Expressions like ‘TUE#2’ still aren’t supported though, which are a part of a cron spec. Might be a useful feature to add.
That's Java's crontab-like syntax, and I've never seen it implemented elsewhere. It is not part of any specification I'm aware of - certainly not POSIX crontab.
from go-crond.
Fair enough, I stand corrected. I guess I will need to stick with the test
workaround for unusual time intervals like “every second Tuesday”.
Edit: Thanks @smlx, I came up with something similar: test $(date +\%u) -eq 2 && /files/job_1.sh
Though even that is not ideal, as it counts as a failure on days other than Tuesday as far as gocrond is concerned, which triggers my alerting :(
from go-crond.
Though even that is not ideal, as it counts as a failure on days other than Tuesday as far as gocrond is concerned, which triggers my alerting :(
You can fix this using an if
statement:
if [ $(date +\%u) = 2 ]; then /files/job_1.sh; fi
from go-crond.
Related Issues (20)
- Catch worker output HOT 1
- OpenShift containers HOT 1
- Segfault with simple commands HOT 7
- Metrics http service always runs HOT 1
- Single files (/etc/crontab) are ignored
- Support standard multiarch binary names HOT 5
- Disabling metrics does not seem to work
- Docker image runs as root HOT 1
- Docker images outdated
- checksum file
- latest tag is not multiarchitecture HOT 1
- [Feature request] Add Shell to LogCronjobToFields
- Output from jobs HOT 3
- Exit status HOT 1
- User specific cronjob use a unclean env vars
- Create releases with https://goreleaser.com/
- Cut a new release HOT 7
- Update release binaries to fix CVEs HOT 1
- Defunct/zombie processes accumulates under go-crond HOT 3
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 go-crond.