ZendHQ JobQueue 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 month, months, and days of the week:

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

Field

Allowed values

Allowed 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

*, , - /

ZendHQ cron expressions allow restricting both day-of-month and 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 month that is also 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 the allowed values of the specific field. For example, * in the month field means "all months from January to December, inclusive".

  • Comma

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

  • Dash

    Dashes (-) define a range of values. For example, 2-4 in the hours field means hours between 2 and 4, inclusive, 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

    Slashes (/) are used to specify incrementor values. Incrementors can be used with ranges and single values. If used with a single value, then the value is changed to a range with a starting value and incrementor.

    Examples:

    • Run every 15 seconds:

      */15 * * * * *

    • Run daily every full hour between 9 and 15 o'clock, and between 16 to 8 o'clock every second full hour:

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