Cron syntax on Azure Functions, AWS, GitHub Actions and Kubernetes compared

•5 min read
Image for Cron syntax on Azure Functions, AWS, GitHub Actions and Kubernetes compared

Copy a six-field cron expression between Azure Functions and AWS EventBridge and you can change its meaning completely. Azure’s explicit six-field form starts with seconds. AWS’s six fields end with a year.

“Every five minutes” is a small requirement. The scheduler still decides what those words mean during downtime, deployment and retries.

TL;DR

  • Select the scheduler dialect before writing the expression.
  • Azure’s seconds field and AWS’s year field are different.
  • Declare a time zone where the platform supports it.
  • Test missed runs and duplicate effects, not only the next matching timestamp.

Every five minutes uses different expressions

These are wall-clock schedules at minutes 00, 05, 10 and so on. They do not mean “wait five minutes after the last execution finishes.”

PlatformExpressionField order
Azure Functions0 */5 * * * *second, minute, hour, day, month, day of week
AWS EventBridgecron(0/5 * * * ? *)minute, hour, day, month, day of week, year
GitHub Actions*/5 * * * *minute, hour, day, month, day of week
Kubernetes CronJob*/5 * * * *minute, hour, day, month, day of week

Use the platform pages in the cron builder: Azure Functions, AWS EventBridge, GitHub Actions and Kubernetes.

The builder helps explain an expression. The deployed platform remains the authority on accepted syntax and execution behavior.

Azure Functions puts seconds first

For a timer trigger, the explicit NCRONTAB form is:

0 */5 * * * *

The leading zero means second zero. Replacing it with * would request every second during each matching minute.

Azure Functions also supports five-field expressions according to the timer documentation. I prefer the explicit seconds form in Functions projects because the precision is visible during review.

The default time zone is UTC. WEBSITE_TIME_ZONE can select another zone on supported hosting plans, but it is not supported on Linux Consumption and Flex Consumption. Do not copy that setting between plans without checking support.

Avoid RunOnStartup = true as a scheduling shortcut. Startup can happen during restarts and scaling, not just at a business-defined time.

AWS distinguishes cron from elapsed intervals

EventBridge’s cron wrapper is part of the schedule expression:

cron(0/5 * * * ? *)

The question mark leaves day of week unspecified while the day-of-month field uses *. AWS does not let both fields carry ordinary specified values in the same way some other cron dialects do.

For a recurring interval rather than specific clock minutes, EventBridge Scheduler also supports:

rate(5 minutes)

EventBridge Scheduler supports named time zones. Legacy EventBridge scheduled rules use UTC. Both products have scheduling features, but their surrounding configuration differs; do not describe them as the same service.

Scheduler uses 60-second invocation precision. A schedule for a given minute is not a promise to execute at second zero.

GitHub Actions is a scheduled workflow, not a precise timer

This complete workflow requests a run every five minutes:

name: Scheduled check
on:
  schedule:
    - cron: '*/5 * * * *'
  workflow_dispatch:
permissions:
  contents: read
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Run the scheduled check"

Scheduled workflows run from the default branch. The minimum interval is five minutes, and runs can be delayed during load. GitHub documents that sufficiently heavy load can also cause queued jobs to be dropped.

Without a time-zone override, interpret this schedule in UTC. For work that does not require the five-minute cadence, moving away from the top of the hour reduces contention.

A scheduled workflow is useful for repository maintenance. It is a poor contract for a customer-facing deadline that must fire at an exact instant.

Kubernetes needs an overlap policy

This CronJob writes a timestamp every five minutes:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: scheduled-check
spec:
  schedule: "*/5 * * * *"
  timeZone: "Etc/UTC"
  concurrencyPolicy: Forbid
  startingDeadlineSeconds: 120
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: check
              image: busybox:1.37
              command: ["sh", "-c", "date -u"]

Forbid prevents overlapping Jobs from this CronJob. It does not lock other CronJobs or external consumers. The starting deadline limits how late a missed execution may start.

The timeZone field is stable from Kubernetes 1.27. Without it, the controller’s local zone determines interpretation. Put the zone in this field, not a TZ prefix inside the cron expression.

Kubernetes documents that scheduling is approximate and can produce duplicate Jobs or miss an occurrence. Your task should tolerate that.

A valid schedule still needs an execution contract

For each recurring job, decide how to handle an execution that lasts longer than its interval. Decide whether a missed run should be caught up, skipped or reconciled from durable business state.

Use an idempotency key tied to the work being performed. For a daily invoice export, that might be the account and export date, rather than a random identifier generated on each retry.

Monitor the last successful completion and the age of pending work. Counting timer invocations alone can hide a job that wakes up on schedule and fails every time.

The cron expression defines eligible times. Reliable work requires a policy for everything that happens after the clock matches.

Thank you for reading.

-Bruno

Author's note: I wrote the recipe and cooked the food, AI just helped with the plating.

Read more