oktools

Cron Syntax Compared: crontab vs Quartz vs Kubernetes vs GitHub Actions

Why an expression that works in one scheduler fails or fires at the wrong time in another: field counts, weekday numbering, the day-of-month trap, special characters and time zones.

The short answer

"Cron expression" is not one syntax. The five-field format from Unix crontab is the common base, and every scheduler built since has kept the look while changing details: how many fields there are, which number means Sunday, which time zone applies, and which special characters exist. An expression copied from one system to another can be rejected, or worse, accepted and run at a different time.

SystemFieldsSunday isTime zoneExtras
Unix crontab50 or 7System local time@daily and other nicknames
Kubernetes CronJob50 or 7Controller's zone unless timeZone is setNicknames
GitHub Actions50UTCNone
Quartz (Java)6 or 7, seconds first1JVM default unless set? L W #
Spring @Scheduled6, seconds first0 or 7Server default unless zone is set? L W #, nicknames
AWS EventBridge6, year last1UTC? L W #

The five fields everyone shares

The classic format is minute, hour, day of month, month, day of week. Each field takes a number, a list (1,15), a range (1-5), a step (*/15) or * for every value. Months and weekdays can also be written as three-letter names.

crontab
┌───────────── minute (0-59)
│ ┌─────────── hour (0-23)
│ │ ┌───────── day of month (1-31)
│ │ │ ┌─────── month (1-12)
│ │ │ │ ┌───── day of week (0-7, 0 and 7 are Sunday)
│ │ │ │ │
0 9 * * 1-5

Here is how the cron expression parser reads a few standard expressions:

0 9 * * 1-5   At 09:00 on Monday through Friday.
*/15 * * * *  Every 15 minutes.
0 0 * * 0     At 00:00 on Sunday.
0 0 * * 7     At 00:00 on Sunday.

The day-of-month and day-of-week trap

Every other pair of fields narrows the schedule: the job runs when the minute and the hour and the month all match. The two day fields are the exception. When both are restricted, standard cron runs the job when either one matches.

Not "Friday the 13th"
0 0 13 * 5
At 00:00 on the 13th of every month, or on Friday.

That expression runs every Friday and also on every 13th, about five times a month rather than once or twice a year. There is no way to say "Friday the 13th" in standard cron fields alone; the usual fix is to schedule every 13th and have the command check the weekday itself. Quartz and EventBridge avoid the ambiguity by making you put ? in one of the two fields.

Six and seven fields: Quartz, Spring and EventBridge

Java schedulers add a seconds field at the front. A five-field expression pasted into Quartz or Spring is either rejected for having too few fields or, if a sixth value follows, read with every field shifted one place. The parser on this site accepts six fields with seconds first:

Six fields
0 0 12 * * ?
Every day at 12:00.

Beyond the extra field, the dialects differ in ways that do not show until the job runs:

  • Weekday numbers. Quartz and EventBridge count Sunday as 1 and Saturday as 7. Standard cron and Spring count Sunday as 0 (or 7) and Monday as 1. So 1-5 means Monday to Friday in crontab and Sunday to Thursday in Quartz. Writing MON-FRI is unambiguous everywhere that accepts names.
  • The ? character means "no specific value" and is required by Quartz and EventBridge in exactly one of the two day fields. Standard crontab does not know it.
  • L means the last day of the month (or, in the weekday field, the last such weekday), W the nearest weekday to a date, and # the nth weekday, as in MON#1 for the first Monday. None exist in standard cron.
  • EventBridge wraps the expression as cron(0 12 * * ? *): no seconds, a year field at the end, and ? mandatory.

The parser tells you when an expression uses one of these extensions rather than failing silently:

Parser message
0 0 L * *
L (last day) is a Quartz extension. Standard cron — and this parser — only understand numbers, * ? , - and /, so day of month cannot use it.

For "the last day of the month" in plain crontab, the common workaround is to run on days 28 to 31 and let the command test whether tomorrow is the 1st.

Which time zone the schedule runs in

This is the most frequent cause of a job firing hours away from when it was expected. The expression itself carries no zone; the system reading it decides.

  • Unix cron uses the machine's local time zone. Some implementations, including cronie on most Linux distributions, accept a CRON_TZ= line in the crontab to override it.
  • Containers almost always run in UTC, whatever the host is set to, so a crontab moved into a container shifts by your UTC offset.
  • A Kubernetes CronJob uses the time zone of the cluster's controller manager, which is UTC on most managed clusters. Since Kubernetes 1.27 you can set spec.timeZone to an IANA name such as Europe/Warsaw.
  • GitHub Actions schedule triggers are in UTC.
  • Quartz and Spring use the server's default zone unless the trigger or the annotation's zone attribute names one.

To work out what a UTC schedule means for you, use the time zone converter, or switch the parser's list of next run times between your zone and UTC.

Daylight saving adds a second problem for local-time schedules. On the night clocks go forward, an hour does not exist, and a job set for 02:30 in that hour is skipped or run late, depending on the scheduler. On the night they go back, an hour happens twice and the job may run twice. Scheduling in UTC, or outside the 01:00 to 03:00 window, avoids both.

Platform limits that are not in the syntax

  • GitHub Actions: the shortest interval is every 5 minutes, runs can start late when the service is busy, and scheduled workflows in a public repository are disabled after 60 days without repository activity.
  • Kubernetes: concurrencyPolicy decides whether a new run may start while the last one is still going, and startingDeadlineSeconds decides how late a missed run may still start. Neither is expressible in the schedule itself.
  • Unix cron does not run jobs that were due while the machine was off. anacron, or a systemd timer with Persistent=true, does.
  • Cron's resolution is one minute. For anything finer you need a six-field scheduler or a loop inside the job.
  • Standard cron has no "every 90 minutes" or "every 45 minutes": steps restart at the top of each hour or day, so */45 runs at :00 and :45 and then again at :00.

Moving an expression between systems

  • Count the fields the target expects and add or remove the seconds (and year) field.
  • Rewrite weekday numbers as names (MON-FRI), or convert them if the target does not take names.
  • Add ? to one day field for Quartz and EventBridge; replace it with * for crontab.
  • Replace L, W and # with a broader schedule plus a check in the command, when moving to standard cron.
  • Convert the hour for the target's time zone, and decide what should happen across a daylight-saving change.
  • Paste the result into the cron expression parser and read the next run times before you deploy it. A timestamp from a log can be checked against them with the Unix timestamp converter.