Specify dates and times using crontab syntax

JobQueue uses a 6-field crontab-like format with an initial seconds field. The ZendHQ cron scheduler uses UTC time. It does not support cron expressions written in your local time zone.

Time format

The cron expression is a list of six space-separated fields representing seconds, minutes, hours, days of the month, months, and days of the week:

<seconds> <minutes> <hours> <day-of-month> <month> <day-of-week>

Field

Valid values

Valid special characters

seconds

0-59

*, , - /

minutes

0-59

*, , - /

hours

0-23

*, , - /

day-of-month

1-31

*, , - /

month

1-12 or JAN-DEC

not case-sensitive

*, , - /

day-of-week

0-7 or SUN-SAT or MON-SUN

not case-sensitive

both 0 and 7 mean Sunday

*, , - /

With ZendHQ cron expressions, you can restrict both the day-of-month and the day-of-week fields. If both are restricted (that is, they do not contain the * character), then, contrary to the traditional cron implementation, both criteria must match the current day for the job to run.

Example:

  • Run at noon every 13th day of the month that is also a Friday:

    0 0 12 13 * FRI

Ranges and periods

To define ranges, use the following special characters:

  • Asterisk

    Asterisks (*) expand to a full list of all valid values of the specific field. For example, an asterisk * in the month field means "all months from January to December, inclusively".

  • Comma

    Use commas (,) to separate items of a list. For example, MON,WED,FRI in the day-of-week field means "Mondays, Wednesdays, and Fridays".

  • Dash

    Use dashes (-) to define a range of values. For example, 2-4 in the hours field means the hours between 2 and 4, inclusively, that is, "2, 3, and 4".

    ZendHQ JobQueue cron expressions also support overflowing ranges like FRI-MON, which is expanded to FRI,SAT,SUN,MON.
  • Slash

    Use slashes (/) to specify incrementer values. Incrementers can be used with ranges and single values. If used with a single value, the value is changed to a range with a starting value and incrementer.

    Examples:

    • Run every 15 seconds:

      */15 * * * * *
    • Run daily every full hour between 9 AM and 3 PM (between 9:00 and 15:00), and then again between 4 PM and 8 AM (between 16:00 and 8:00) every second full hour:

      0 0 9-15,16-8/2 * * *