Deployment Guide
Configuration Guide 31
8
Cron Expressions
This section explains how to use cron expression formats and special characters.
Introduction to Cron Expressions
Cron is a UNIX tool that has been around for a long time, so its scheduling capabilities are powerful and proven. The
CronTrigger class is based on the scheduling capabilities of cron.
CronTrigger uses cron expressions, which are able to create firing
schedules such as at 8:00am every Monday through
Friday or at 1:30am every last Friday of the month.
Cron expressions are powerful, but can be confusing.
This document aims to take some of the mystery out of creating a
cron expression, giving you a resource to use before seeking outside help.
Cron Expression Formats
Cron expressions are comprised of 6 required fields and 1 optional field, separated by white space. Fields can contain any
of the allowed values, along with various combinations of the allowed special characters for that field.
Cron expressions can be as simple as * * * * ? *.
Or more complex, such as 0 0/5 14,18,3-39,52 ? JAN,MAR,SEP MON-FRI 2002-2010.
The fields are described as follows.
Field Name Mandatory? Allowed Values Allowed Special Characters
Minutes Yes 0-59 , - * /
Hours Yes 0-23 , - * /
Day of month Yes 1-31 , - * ? / L W C
Month Yes 1-12 or JAN-DEC , - * /
Day of week Yes 1-7 or SUN-SAT , - * ? / L C #
Year No empty, 1970-2099 , - * /
Special Characters
• The * character is used to specify all values. For example, * in the minute field means every minute.
• The ? character (no specific value) is useful when you need
to specify something in one of the two fields in which the
character is allowed, but not the other. For example, to trigger a fire on a particular day of the month (the 10th), but you
do not care what day of the week that happens to be, use 10 in the day-of-month field, and ? in the day-of-week field.
• The - character is used to specify ranges. For example, 10
-12 in the hour field means the hours 10, 11, and 12.
• The , character is used to specify additional values. For
example, MON,WED,FRI in the day-of-week field means the
days Monday, Wednesday, and Friday.