Writing a cron expression v7

A cron expression is a text string used to express a schedule of dates and times. The Linux cron tool uses a cron expression to schedule the execution of a job. Replication Server uses the Quartz job scheduling system for scheduling replications.

When creating a schedule for a Replication Server replication system, you can specify a cron expression. There are a number of formats for cron expressions. You must use the cron expression format supported by Quartz.

For a comprehensive treatment of cron expressions, refer to the Quartz documentation.

A Quartz cron expression consists of six mandatory fields followed by one optional field. Each field is separated from its neighbors by one or more consecutive space characters. The fields are order dependent and are listed as they must appear as follows:

ss mi hr dd mm dow [ yyyy ]

ss0 - 59Second of the minute
mi0 - 59Minute of the hour
hr0 - 23Hour of the day
dd1 - 31 or ?Day of the month – if dow is given, then dd must be specified as ?
mm1 - 12 or JAN - DECMonth of the year (3-letter month abbreviations aren't case sensitive)
dow1 – 7 or SUN – SAT or ?Day of the week – if dd is given, then dow must be specified as ? (3-letter day of the week abbreviations are not case sensitive)
yyyy1970 - 2099Year – if omitted, then any year applies

A number of characters have special meaning that you can use in all fields unless noted.

,Separates a list of valuesMON,WED,FRI – Every Monday, Wednesday, and Friday
-Separates the low and high end of a range of valuesMON-FRI – Every Monday through Friday
*Allows all legal values for the field0 10 14 * * ? – Every day of every month at 2:10 PM
x/iSpecifies an increment, i, starting with x0 0/10 * * * ? – Every 10 minutes starting on the hour for every day of every month (e.g., 8:00:00, 8:10:00, 8:20:00)
LWhen used in the day of the month (dd) field, means the last day of the month0 30 15 L 8 ? – Every August 31st at 3:30 PM
LWhen used by itself in the day of the week field (dow), means Saturday30 0 12 ? AUG L – The next Saturday in August at 30 seconds past 12:00 noon
xxxLWhen used in the day of the week field (dow) following a day of the week, means the last xxx day of the month30 0 12 ? AUG 6L – The last Friday in August at 30 seconds past 12:00 noon
xWUsed in the day of the month field (dd) following a day of the month, x, to specify the weekday closest to x without going over into the next or previous month.1W – The weekday closest to the 1st of the month. If the 1st is a Wednesday, the result is Wednesday the 1st. If the 1st is a Sunday, the result is Monday the 2nd. If the 1st is a Saturday, the result is Monday the 3rd because the result does not go into the previous or following month.
xxx#nUsed in the day of the week field (dow) to specify the nth xxx day of the month2#3 – The third Monday of the month (2 = Monday, 3 = third occurrence)

The following are some examples of cron expressions.

Cron expressionMeaning
Cron ExpressionMeaning
0 0 12 20 AUG ? 200912:00:00 noon on August 20, 2009
0 15 13 ? AUG WED1:15:00 PM every Wednesday in August
30 30 8 ? * MON,WED,FRI8:30:30 AM every Monday, Wednesday, and Friday of every month
0 0 8 ? * 2-68:00:00 AM Monday thru Friday of every month
0 0/30 8,9,10 15,L * ?8:00:00 AM, 8:30:00 AM, 9:00:00 AM, 9:30:00 AM, 10:00:00 AM, 10:30:00 AM on the 15th and the last day of the month of every month
0 0 9 ? 9 L9:00:00 AM each Saturday in September
0 0 1 ? * MonL1:00:00 AM on the last Monday of the month of every month
0 30 16 15W sep ?4:30:00 PM on the weekday of September closest to the 15th
0 30 16 ? * WED#24:30:00 PM on the second Wednesday of every month