Cron schedule

A "cron" schedule is made up of six or seven sub-fields that together describe when the robots should be run. The sub-fields are separated with one or more spaces and represent:

  1. Seconds
  2. Minutes
  3. Hours
  4. Day-of-Month
  5. Month
  6. Day-of-Week
  7. Year (optional field)

An example of a complete cron schedule is "0 0 12 ? * WED", which means "every Wednesday at 12:00 pm".

Individual sub-fields can contain ranges and/or lists. For example, the Day-of-Week field in the previous example (that is, "WED") could be replaced with "MON-FRI", "MON, WED, FRI", or even "MON-WED,SAT".

Wildcards (the "*" character) can also be used, meaning "every possible value of this field". For example, the "*" character in the Month field of the previous example would mean "every month". A "*" in the Day-of-Week field would mean "every day of the week".

The set of valid values for each field is:

  • Seconds: The numbers 0 to 59.
  • Minutes: The numbers 0 to 59.
  • Hours: The numbers 0 to 23.
  • Day-of-month: The numbers 1 to 31 (take into account many days a given month has).
  • Month: The numbers 1 to 12, or the strings JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, and DEC.
  • Day-of-week: The number 1 to 7 (1 is Sunday), or the strings SUN, MON, TUE, WED, THU, FRI, and SAT.
  • Year: Any number.

In addition, a number of special characters may be used:

Definition

/

Specifies increments to values. For example, if you put "0/15" in the Minutes field, it means "every 15 minutes, starting at minute zero". If you use "3/20" in the Minutes field, it means "every 20 minutes during the hour, starting at minute three". In other words, it is the same as specifying "3,23,43".

?

Allowed only in the Day-of-Month and Day-of-Week fields and means "no specific value". This is useful when you need to specify something in one of these two fields, but not the other. See the examples below for clarification.

L

Allowed only in the Day-of-Month and Day-of-Week fields. "L" is short-hand for "last", but its meaning differs between the two fields.

In the Day-of-Month field, "L" means "the last day of the month" - day 31 for January, day 28 for February on non-leap years, and so on.

If used in the Day-of-Week field by itself, it means "7" or "SAT", but if used in the Day-of-Week field after another value, it means "the last xxx day of the month" . For example, "6L" or "FRIL" both mean "the last Friday of the month".

When using the "L" character, it is important not to specify lists or ranges of values, as you will get confusing results.

#

Used in the Day-of-Week field to specify "the nth" XXX weekday of the month. For example, the value of "6#3" or "FRI#3" means "the third Friday of the month".

W

Specifies the weekday (Monday-Friday) nearest the given day. As an example, if "15W" is specified as the value for the Day-of-Month field, the meaning is: "the nearest weekday to the 15th of the month".

Examples

Cron schedule

Explanation

0 0 12 * * ?

Fire at 12pm (noon) every day

0 15 10 ? * *

Fire at 10:15am every day

0 15 10 * * ?

Fire at 10:15am every day

0 15 10 * * ? *

Fire at 10:15am every day

0 15 10 * * ? 2005

Fire at 10:15am every day during the year 2005

0 * 14 * * ?

Fire every minute starting at 2pm and ending at 2:59pm, every day

0 0/5 14 * * ?

Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day

0 0/5 14,18 * * ?

Fire every 5 minutes starting at 2pm and ending at 2:55pm,

AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day

0 0-5 14 * * ?

Fire every minute starting at 2pm and ending at 2:05pm, every day

0 10,44 14 ? 3 WED

Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.

0 15 10 ? * MON-FRI

Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday

0 15 10 15 * ?

Fire at 10:15am on the 15th day of every month

0 15 10 L * ?

Fire at 10:15am on the last day of every month

0 15 10 ? * 6L

Fire at 10:15am on the last Friday of every month

0 15 10 ? * 6L

Fire at 10:15am on the last Friday of every month

0 15 10 ? * 6L 2002-2005

Fire at 10:15am on every last Friday of every month during the years 2002, 2003, 2004 and 2005

0 15 10 ? * 6#3

Fire at 10:15am on the third Friday of every month