Print

Previous Topic

Next Topic

CRON expressions

The job schedule time expression, see Directory Integration import process and file formats, is a string comprised of six or seven fields separated by white space that represents a set of times, normally as a schedule to execute some routine. Fields can contain any of the allowed values, along with various combinations of the allowed special characters.

 

Note: CRON jobs are run in the GMT time zone.

The CRON expression fields are as follows:

 

Field Sequence

Field Name

Mandatory

Allowed Values

Allowed Special Characters

1st

Seconds

 

0-59

, - * /

2nd

Minutes

YES

0-59

, - * /

3rd

Hours

YES

0-23

, - * /

4th

Day of Month

YES

1-31

, - * ? / L W

5th

Month

YES

1-12 or JAN-DEC

, - * /

6th

Day of Week

YES

0-7 or SUN-SAT

, - * ? / L #

7th

Year

NO

empty, 1970-2099

, - * /

Special characters

  • * ("all values") - used to select all values within a field. For example, "" in the minute field means *"every minute".
  • ? ("no specific value") - used to specify something in one of the two fields in which the character is allowed, but not the other. For example, to schedule a job to run on a particular day of the month, but any day of the week, enter "10" in the day-of-month field, and "?" in the day-of-week field. See the examples below for clarification.
  • - - used to specify ranges. For example, "8-10" in the hour field means "the hours 8, 9 and 10".
  • , - used to specify additional values. For example, "JAN,MAR,MAY" in the month field means "the months January, March, and May".
  • / - used to specify increments of ranges. For example, 5-59/30 in the 1st field (minutes) indicate the fifth minute of the hour and every thirty minutes thereafter. You can also specify '/' after the '' character - in this case '' is the equivalent of '0' before the '/'. '1/5' in the day-of-month field indicates that the job is scheduled every five days starting on the first day of the month.
  • L ("last") - performs differently in each of the two fields in which it is allowed. For example, the value "L" in the day-of-month field indicates "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If entered as a standalone special character in the day-of-week field, it indicates "7" or "SAT". When entered in the day-of-week field, you can specify schedules such as "the last Friday" ("5L") of a given month. When using the 'L' option, do not specify lists, or ranges of values.
  • W ("weekday") - used to specify the weekday (Monday-Friday) nearest the given day. For example, entering "20W" in the day-of-month field, indicates "the nearest weekday to the 20th of the month". If the 20th is a Wednesday, the job will run on Wednesday the 20th. However, if the 20th is a Saturday, the job will run on Friday the 19th. Similarly, if the 20th is a Sunday, the job will run on Monday the 21st. However, if you enter "1W" as the value for day-of-month, and the 1st is a Saturday, the job will run on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.

The 'L' and 'W' characters can also be combined in the day-of-month field. 'LW', indicates the *"last weekday of the month"*.

  • # - used to specify "the nth" XXX day of the month. It can be entered in the day-of-week field, and must be followed by a number between one and five. It allows you to specify, for example, "the first Monday" of a given month "2#1" or "4#5", the fifth Wednesday of the month. However, if you specify "#5" and there is not 5 of the given day-of-week in the month, the job will not run that month.

     

     

    Note: The characters and the names of months and days of the week are not case sensitive. MON is the same as mon.

     

Examples

 

Expression

Meaning

0 0 12 * * ?

Scheduled for 12pm (noon) every day.

0 30 11 ? * *

Scheduled for 11:30am every day.

0 30 11 * * ?

Scheduled for 11:30am every day.

0 30 11 * * ? *

Scheduled for 11:30am every day.

0 * 14 * * ?

Scheduled for every minute starting at 2pm and ending at 2:59pm, every day.

0 0/5 14 * * ?

Scheduled for every 5 minutes starting at 2pm and ending at 2:55pm, every day.

0 0/5 14,18 * * ?

Scheduled for every 5 minutes starting at 2pm and ending at 2:55pm, AND run every 5 minutes starting at 6pm and ending at 6:55pm, every day.

0 0 12 1/5 * ?

Scheduled for 12pm (noon) every 5 days every month, starting on the first day of the month.

 

Note:

  • We do not currently support specifying both a day-of-week and a day-of-month value. You must enter the '?' character in one of these fields.
  • Be aware of "daylight savings" time when scheduling jobs to run between mid-night and 1:00 AM. The change in the hour causes a skip or a repeat depending on whether the time is adjusted forward or back.

Top of Page   Print