Schedule Jenkins

This article explains how to properly set up your Perfecto runs using Jenkins scheduling.

In general, the main structure of the scheduler is as follows:

  1. MINUTES: Minutes in one hour (0-59)
  2. HOURSL Hours in one day (0-23)
  3. DAYMONTH: Day in a month (1-31)
  4. MONTH: Month in a year (1-12)
  5. DAYWEEK: Day of the week (0-7), where 0 and 7 are both Sunday

If we want to schedule a run for 8 o’clock every day, type the following:

0 8 * * *  

If we want to schedule a run for 8 o’clock every Monday, type the following:

0 8 * * 1

You might get a Warning at the bottom of the field that recommends you to use “H.” H is used for load balancing and basically means a start in the given interval. It is not random because it is a hash from the name. Therefore, if you remove it and put it back, you will have the same starting time, thus giving a steady time every run.

To start the run between 8:00-8:59, type the following:

H 8 * * *                    - Between 8-9 o’clock

Beneath the warning, you can see an example of the last and next run of the schedule. This is useful and can help estimate when the next and last runs would be/have been, and it also helps with checking if you have set this up correctly.

For a periodic run, use “/” to start the run:

  • every tenth minute of an hour:

    */10 * * * *
  • every ten minutes:

    H/10 * * * *
  • exactly at 8:00, 8:10, 8:20, 8:30, 8:40 and 8:50 (seconds may vary):

    */10 8 * * *

To describe an interval, type “-” to start the run:

  • at 8 o’clock on Monday, Tuesday and Wednesday:

    0 8 * * 1-3
  • randomly between 19:00 and 19:15:

    H(0-15) 19 * * * 
  • every 5 minutes in the time interval 19-20 o’clock:

    */5 19-20 * * * 
  • every 2 hours in the time interval 8-17 o’clock:

    * 8-17/2 * * * 
  • every five minutes every hour in the interval 0-29 mins:

    H(0-29)/5 * * * *

To list different options, use “,” to start the run:

  • at 8 o’clock and 12 o’clock on Monday, Tuesday and Wednesday

    0 8,12 * * 1-3 
  • at 8 o’clock, 12 o’clock and 15 o’clock on Monday

    0 8,12,15 * * 1 

For combinations, add a new schedule on a new line to start the run:

  • at 8 o’clock on Monday and at 8 o’clock on Sunday

    0 8 * * 1 
    0 8 * * 0  

A good practice for worldwide teams is the usage of Time Zones. Just add the following line on the top of the field:

TZ=Zone/TImezone

For a list of all time zones, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. Open the link and choose among the results in the “TZ database name” column:

Best practices:

  1. Usage of “H” is recommended when triggering few tests at once.
  2. Usage of firm numbers is recommended when the time needs to be well-calculated
  3. Schedule your runs in accordance to the run of your Perfecto changes and cloud upgrades schedule.

See also the Perfecto Knowledgebase.