Schedule Jenkins Build Execution During Specific Times using Build periodically: (* * * * * *)? - jenkins

Schedule Jenkins Build Execution During Specific Times using Build periodically: (* * * * * *)?
For example: * * * * * * will execute builds continuously,
Is there a way to use the above approach but to run builds continuously between lets say 9am until 11pm.
Example:
Monday: time of execution: 9am until 11pm.
Tuesday: time of execution: 9am until 11pm.

To run jobs between 9am - 11pm every day, you could use the following:
* 9-23 * * *
To run jobs between 9am - 11pm only on Monday, you can use:
* 9-23 * * 1
And likewise for Tuesday:
* 9-23 * * 2
This website is a great resource for experimenting with cron job formats, and seeing a "human translation" for the syntax.

I think you can use the following cron expression : H 9-23 * * *
To build your own new cron expression keep the following link handy and test in Jenkins:
https://www.freeformatter.com/cron-expression-generator-quartz.html

Related

"H 5 * * 7" cron in Jenkins groovy script

I am trying to understand when this trigger runs in Jenkins groovy script. Seems to me that Jenkins groovy script has some DSL for cron. Does anyone know when this cron job is triggered?
triggers {
cron('H 5 * * 7')
}
In H 5 * * 7 the H means hash. You can have digit in the first place, but H allows to distribute the load better.
H = minute when less load is expected, Jenkins will propose it the first time, after that it will stay more or less the same, if there are available agents to handle it.
5 = hour,
* = any value (every day),
* = any value (every month),
7 = 7th day of week (Sunday).
Reference:
Spread load evenly by using ‘H * * * *’ rather than ‘5 * * * *’
You can test it using the CRONTab tester.
This means to start at 5:00 on every sunday
https://crontab.guru/#0_5_*_*_7

jenkins cron: run every 3rd minute, starting at 1

I want to set Jenkins to run a job every 3rd minute, but not starting at 0. Basically, I have 3 jobs and I want to cycle through them each minute.
The first job I can run every 3rd minute with */3 * * * *. But the second I tried 1/3 * * * * and it failed with hudson.remoting.ProxyException: line 1:2: unexpected token: /
How do I write this expression?
I think you're looking for:
job 1: 0-57/3 * * * *
job 2: 1-58/3 * * * *
job 3: 2-59/3 * * * *
Think of the cron minute entry as meaning "range/step" (or, "run this every step minutes over the minute range start-end)
Reference: I was able to figure it out from this excellent answer, which includes some helpful related links and a more in-depth explanation.

Schedule a Jenkins Job to run hourly everyday but skip midnight (00:00) and resume again from 01:00 till 23:00

I have a Jenkins job which I would like to run from (01:00) 1 AM till (23:00) 11PM but skip midnight (00:00) and resume again from (01:00) on a daily basis. The thread How to schedule Jenkins job every Hour for the next 12 hours had this example H 9-21 * * * which i have changed to H 1-23 * * * to cater for my example.
Am I on the right track perhaps with using H 1-23 * * * ??
Yes, that should work. There is a cron tester you can look that will show you the cron version of that, and for Jenkins you just replace the 0 with the H.
http://cron.schlitt.info/index.php?cron=0+1-23+*+*+*+&iterations=50&test=Test

Run a Jenkins job every one minute using H/1 * * * *

How can I run a job created in Jenkins every one minute ? Am I missing anything?
PS: I'm trying not to use: */1 * * * *
Try * * * * * to run every minute.
Unfortunately H/1 * * * * does not work due to open defect.
Defect: https://issues.jenkins-ci.org/browse/JENKINS-22129
Your intuition is right, H/1 is supposed to behave like "run every minute".
However, there is a well-known bug in Jenkins. See JENKINS-22129.
Currently, H/1 behaves like "run every hour".
Use this format it will Run a Jenkins job every one minute "* * * * *"
To run the build process every minute,
check the Build periodically option and add * * * * *

How to schedule job in Jenkins every 4 hours and 10 minutes

I made jobs to start at every 4 hours H */4 * * *
But I can't schedule at 4:10
I tried 10 */4 * * * and H/10 */4 * * *
Unfortunately no luck
Configuring a fixed time is very simple:
10 4 * * *
Your 10 */4 * * * means "run it every 4 hours, at minute 10".
See also http://www.adminschoice.com/crontab-quick-reference/ for reference.
EDIT
Sorry, from the description it seems you want to run it at exactly 4.10, but I then realized that in the title you say something different: every 4h and 10'. Do you mean e.g. at [1.10, 5.20, 9.30]? If so, try */10 */4 * * *.
Please provide an example with a sequence of times you expect, e.g. [2.10, 3.20, 4.30], so that it's more clear what you want.

Resources