How schedule build in Jenkins?

deadfish picture deadfish · Aug 9, 2011 · Viewed 276k times · Source

How do I schedule a Jenkins build such that it would be able to build only at specific hours every day?

For example to start at 4 PM

0 16 1-7 * *

I understand that as: 0 minutes, at 4 o'clock PM from Monday to Sunday every month, however it builds every minute :(

I would be grateful for any advice. Thanks!

Answer

Zach Young picture Zach Young · Aug 10, 2011

Please read the other answers and comments, there’s a lot more information stated and nuances described (hash functions?) that I did not know when I answered this question.

According to Jenkins' own help (the "?" button) for the schedule task, 5 fields are specified:

This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace: MINUTE HOUR DOM MONTH DOW

I just tried to get a job to launch at 4:42PM (my approximate local time) and it worked with the following, though it took about 30 extra seconds:

42 16 * * *

If you want multiple times, I think the following should work:

0 16,18,20,22 * * *

for 4, 6, 8, and 10 o'clock PM every day.