The DevOps Drop

Cron expression: every 2 hours

To run a job every 2 hours, use 0 */2 * * *. Below is the same schedule for crontab, Kubernetes, GitHub Actions, systemd timers and AWS EventBridge.

Adjust this schedule in the cron tool →

In plain English

Every 2 hours, on the hour.

Next runs (UTC):

  • Sun 6 Dec 2026, 10:00
  • Sun 6 Dec 2026, 12:00
  • Sun 6 Dec 2026, 14:00
  • Sun 6 Dec 2026, 16:00
  • Sun 6 Dec 2026, 18:00

crontab

0 */2 * * * /path/to/command

Add it with crontab -e. It runs in the server's local time zone (usually UTC on servers).

Kubernetes CronJob

apiVersion: batch/v1
kind: CronJob
metadata:
  name: my-job
spec:
  schedule: "0 */2 * * *"
  timeZone: "Etc/UTC"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: my-job
              image: busybox:1.36
              command: ["sh", "-c", "echo Hello from my-job"]

timeZone is supported from Kubernetes 1.27. Without it, the schedule uses the controller manager's time zone (usually UTC). concurrencyPolicy: Forbid stops a slow run overlapping the next one.

GitHub Actions

on:
  schedule:
    - cron: '0 */2 * * *'

Scheduled workflows run in UTC, on the latest commit of the default branch. Runs can start late or be dropped when GitHub is busy, so avoid relying on exact timing.

systemd timer

[Unit]
Description=Run my-job on a schedule

[Timer]
OnCalendar=*-*-* 00/2:00:00
Persistent=true

[Install]
WantedBy=timers.target

Save it as my-job.timer next to a my-job.service, then run systemctl enable --now my-job.timer. Check the schedule with systemd-analyze calendar "*-*-* 00/2:00:00". Times use the server's local time zone unless you add one to the end, e.g. *-*-* 00/2:00:00 Europe/London.

AWS EventBridge

cron(0 0/2 * * ? *)

EventBridge uses six fields (the last is the year), numbers days of the week 1–7 from Sunday, and needs ? in either the day-of-month or day-of-week field. Rules run in UTC; EventBridge Scheduler lets you choose a time zone.

Other common schedules

Cron syntax explained

A standard cron expression has five fields, separated by spaces:

┌───────────── minute (0–59)
│ ┌───────────── hour (0–23)
│ │ ┌───────────── day of month (1–31)
│ │ │ ┌───────────── month (1–12 or JAN–DEC)
│ │ │ │ ┌───────────── day of week (0–6 or SUN–SAT; 7 is also Sunday)
│ │ │ │ │
* * * * *
SymbolMeaningExample
*Every value* * * * *: every minute
,A list of values0 9,17 * * *: 09:00 and 17:00
-A range0 9 * * 1-5: weekdays at 09:00
/A step*/15 * * * *: every 15 minutes

How the formats differ

FormatFieldsTime zoneWatch out for
crontab5Server's local timeDay-of-month and day-of-week are OR'd when both are set
Kubernetes CronJob5timeZone field (1.27+)Missed runs and overlap: set concurrencyPolicy and startingDeadlineSeconds
GitHub Actions5UTCMinimum 5 minutes; runs can be delayed or dropped
systemd timerOnCalendarLocal, or a zone at the endEvery part of a line must match; use Persistent=true to catch up missed runs
AWS EventBridge6 (adds year)UTC (Scheduler: any)Days of week are 1–7 from Sunday; one day field must be ?