jenkinsbuildcronscheduletimetable

How to schedule a build in Jenkins?


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, "at 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!


Solution

  • Update: please read the other answers and comments as they contain more info (e.g., hash functions) that I did not know when I first 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.