My Sites


Thursday, November 5, 2015

How to schedule jobs (Cron) in Jenkins

Cron job - run periodically at fixed times, dates, or intervals.

A CRON expression is a string comprising five or six fields separated by white space[10] that represents a set of times, normally as a schedule to execute some routine.
    MINUTES Minutes in one hour (0-59)
    HOURS Hours in one day (0-23)
    DAYMONTH Day in a month (1-31)
    MONTH Month in a year (1-12)
    DAYWEEK Day of the week (0-7) where 0 and 7 are sunday

If you want to shedule your build every 5 minutes, this will do the job : */5 * * * *
If you want to shedule your build every day at 8h00, this will do the job : 0 8 * * *
15 13 * * * you tell jenkins to schedule the build every day of every month of every year at the 15th minute of the 13th hour of the day. (13:15)

http://www.unixgeeks.org/security/newbie/unix/cron-1.html

01 * * * * root echo "This command is run at one min past every hour"
17 8 * * * root echo "This command is run daily at 8:17 am"
17 20 * * * root echo "This command is run daily at 8:17 pm"
00 4 * * 0 root echo "This command is run at 4 am every Sunday"
* 4 * * Sun root echo "So is this"
42 4 1 * * root echo "This command is run 4:42 am every 1st of the month"
01 * 19 07 * root echo "This command is run hourly on the 19th of July"

1 comment: