On this page
Cron syntax
You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules
Fields order
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0)
| | | | |
* * * * *
Each of the patterns from the first five fields may be either * (an asterisk),
which matches all legal values, or a list of elements separated by commas (see below).
For "day of the week" (field 5), 0 is considered Sunday, 6 is Saturday
(7 is an illegal value)
A job is executed when the time/date specification fields all match the current
time and date. There is one exception: if both "day of month" and "day of week"
are restricted (not "*"), then either the "day of month" field (3) or the "day of week"
field (5) must match the current day (even though the other of the two fields
need not match the current day).
Fields operators
There are several ways of specifying multiple date/time values in a field:
- The comma (',') operator specifies a list of values, for example: "1,3,4,7,8"
- The dash ('-') operator specifies a range of values, for example: "1-6", which is equivalent to "1,2,3,4,5,6"
- The asterisk ('*') operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to 'every hour' (subject to matching other specified fields).
- The slash ('/') operator (called "step") can be used to skip a given number of values. For example, "*/3" in the hour field is equivalent to "0,3,6,9,12,15,18,21".
- The plus ('+') operator (called "offset") can be used as an offset to a given range. For example, "*/10+2" in the minute field is equivalent to "2,12,22,32,42,52".
- The ('@') operator (system generated offset) can be used to automatically skew jobs in order to prevent spikes. '(@)' is an incremental value generated by Ultimate Cron. For example, "*/10+@" in the minute field will be translated into "0,10,20,30,40,50", "1,11,21,31,41,51", etc.
Examples
*/15 * * * * : Execute job every 15 minutes
*/15+@ * * * * : Execute job every 15 minutes, but add a system generated offset.
0 2,14 * * *: Execute job every day at 2:00 and 14:00
0 2 * * 1-5: Execute job at 2:00 of every working day
0 12 1 */2 1: Execute job every 2 month, at 12:00 of first day of the month OR at every monday.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion