DEV Community

Cover image for Same Cron Line, Different Schedule: 5 Ways It Changes Meaning on GitHub Actions, Kubernetes and Cloudflare
FindUtils
FindUtils

Posted on

Same Cron Line, Different Schedule: 5 Ways It Changes Meaning on GitHub Actions, Kubernetes and Cloudflare

A cron line looks like the most portable thing in your repo. 0 9 * * 1 is five fields, and every scheduler accepts five fields. So when a job moves from a server's crontab to a GitHub Actions workflow, a Kubernetes CronJob or a Cloudflare Worker, the line usually gets copied as is.

The text survives the move. What it means doesn't always survive. I took a handful of everyday lines and checked them in two ways:

  • Ran them through two cron libraries on my machine: croniter 6.2.4 (Python, classic crontab rules) and robfig/cron v3.0.1 (Go), which is the parser the Kubernetes CronJob controller imports (it's listed in Kubernetes' own go.mod).
  • Read the current docs for GitHub Actions, Kubernetes and Cloudflare Cron Triggers for anything I couldn't run.

I didn't run jobs on a real cluster, a real GitHub repository or a real Worker, so the platform rows below are what the docs say, and the library rows are what I measured. Here are the five differences that change when a job runs, plus a few that change whether it runs.

1. The time zone is not in the line

0 9 * * 1-5 means "09:00 on weekdays", but 09:00 where? The line doesn't say, so the platform decides:

  • A server crontab: the server's local time zone.
  • GitHub Actions: UTC by default. The schedule docs now also accept an optional timezone: with an IANA name next to the cron: line.
  • Kubernetes: the kube-controller-manager's local time zone, unless you set .spec.timeZone (stable since v1.27, per the CronJob docs).
  • Cloudflare Cron Triggers: UTC, per the Cron Triggers docs.

Here's the same line, read in three zones, for the first run on Monday 30 November 2026:

"0 9 * * 1-5" read in UTC               -> first run Mon 2026-11-30 09:00 local = 09:00 UTC
"0 9 * * 1-5" read in Europe/Istanbul   -> first run Mon 2026-11-30 09:00 local = 06:00 UTC
"0 9 * * 1-5" read in America/New_York  -> first run Mon 2026-11-30 09:00 local = 14:00 UTC
Enter fullscreen mode Exit fullscreen mode

Copy a New York team's 09:00 report from a server to a UTC-only scheduler, and it lands at 04:00 New York time. And if you "fix" it by converting to UTC once, it breaks again twice a year:

09:00 New York on Fri 2026-10-30 = 13:00 UTC
09:00 New York on Mon 2026-11-02 = 14:00 UTC
09:00 New York on Fri 2027-03-12 = 14:00 UTC
09:00 New York on Mon 2027-03-15 = 13:00 UTC
Enter fullscreen mode Exit fullscreen mode

A fixed UTC hour drifts by an hour against local time when daylight saving time starts or ends. If the job must follow local time, set the zone on the platform (timezone: on GitHub, .spec.timeZone on Kubernetes). On a UTC-only scheduler, you have to accept the drift or run two lines and skip the wrong one in code.

One related trap: Kubernetes' docs say a CRON_TZ= or TZ= prefix inside .spec.schedule is rejected with a validation error. robfig/cron itself happily parsed CRON_TZ=Europe/Berlin 0 9 * * * in my test, so a library test passing doesn't mean the cluster will accept it.

2. "1" is Monday, except where it's Sunday

In crontab, GitHub Actions and Kubernetes, the day-of-week field runs 0-6 with 0 = Sunday, so 1 is Monday. Cloudflare's docs say their weekdays go 1-7, with 1 = Sunday and 7 = Saturday, and they point out the difference themselves.

So 0 9 * * 1 is a Monday job on three platforms and a Sunday job on Cloudflare. And 7 differs too:

"0 9 * * 7": croniter -> Sun 2026-11-29 09:00 UTC | Sun 2026-12-06 09:00 UTC
             robfig   -> ERROR: end of range (7) above maximum (6): 7
Enter fullscreen mode Exit fullscreen mode

croniter accepts 7 as Sunday (as many crontabs do), the Kubernetes parser rejects it, and Cloudflare reads it as Saturday. The fix is easy: use names. MON-FRI parsed in both libraries, and all three platforms' docs list three-letter names.

3. Both day fields set means OR, not AND

You want a job on Friday the 13th, so you write 0 0 13 * 5. Here's what both libraries scheduled:

## Both day fields set (13th of the month, Friday)
   croniter: Fri 2026-12-04 00:00 UTC | Fri 2026-12-11 00:00 UTC | Sun 2026-12-13 00:00 UTC | Fri 2026-12-18 00:00 UTC | Fri 2026-12-25 00:00 UTC
   robfig:   Fri 2026-12-04 00:00 UTC | Fri 2026-12-11 00:00 UTC | Sun 2026-12-13 00:00 UTC | Fri 2026-12-18 00:00 UTC | Fri 2026-12-25 00:00 UTC
   croniter day_or=False (AND, "Friday the 13th"): Fri 2027-08-13 00:00 UTC | Fri 2028-10-13 00:00 UTC
Enter fullscreen mode Exit fullscreen mode

Every Friday and every 13th. This is the classic cron rule: when both day-of-month and day-of-week are restricted, a day matches if either one matches. If one of them is *, it's ignored, which is why 0 0 * * 5 is simply "every Friday". The job you meant runs about once a year; the job you wrote runs about five times a month.

Cron can't express "Friday the 13th" on its own. Schedule the wider pattern (0 0 13 * *) and check the weekday in the job's first line.

I also built this schedule in the FindUtils Cron Expression Generator. It produced 0 0 1,13 * 5 (day 1, the default, stayed selected in my run), described it as "At 00:00, on days 1 and 13 of the month, Friday", and listed no upcoming runs. 0 0 1 * 1 gave the same empty list. The description can be read as AND, while cron runs it as OR, so for schedules with both day fields set, trust the libraries' run list, not the description. In the one single-day-field check I made (its "Monday 9 AM" preset, 0 9 * * 1), the run list matched both libraries.

4. Steps restart at the top of every hour

*/7 reads like "every 7 minutes". It's actually "minutes divisible by 7", restarted every hour:

## Every 7 minutes?
   croniter: Sun 2026-11-29 10:56 UTC | Sun 2026-11-29 11:00 UTC | Sun 2026-11-29 11:07 UTC | Sun 2026-11-29 11:14 UTC | Sun 2026-11-29 11:21 UTC
## Every 45 minutes?
   croniter: Sun 2026-11-29 10:45 UTC | Sun 2026-11-29 11:00 UTC | Sun 2026-11-29 11:45 UTC | Sun 2026-11-29 12:00 UTC | Sun 2026-11-29 12:45 UTC
## Every 5 hours?
   croniter: Sun 2026-11-29 20:00 UTC | Mon 2026-11-30 00:00 UTC | Mon 2026-11-30 05:00 UTC | Mon 2026-11-30 10:00 UTC | Mon 2026-11-30 15:00 UTC
Enter fullscreen mode Exit fullscreen mode

robfig gave identical times in all three cases. */7 leaves a 4-minute gap from :56 to :00, */45 runs at :00 and :45 (15 minutes, then 45), and 0 */5 * * * runs at 20:00 and then again 4 hours later at midnight. Cloudflare's docs give the same */45 example ("at minutes 0 and 45 of every hour, not every 45 minutes").

Steps only give an even rhythm when they divide the range: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20 or 30 for minutes, and 1, 2, 3, 4, 6, 8 or 12 for hours. For anything else, list the times explicitly or let the job decide based on the last run time.

5. Daylight saving time: the 02:30 job that vanished

Once you set a time zone that has daylight saving time, an hour of local time disappears in spring and repeats in autumn. In Berlin in 2027 the clocks go from 02:00 to 03:00 on 28 March and from 03:00 back to 02:00 on 31 October. A daily 30 2 * * * job:

## Spring forward: 02:30 does not exist
   croniter: Sat 2027-03-27 02:30 CET | Sun 2027-03-28 03:00 CEST | Mon 2027-03-29 02:30 CEST | Tue 2027-03-30 02:30 CEST | Wed 2027-03-31 02:30 CEST
   robfig:   Sat 2027-03-27 02:30 CET | Mon 2027-03-29 02:30 CEST | Tue 2027-03-30 02:30 CEST | Wed 2027-03-31 02:30 CEST | Thu 2027-04-01 02:30 CEST
## Fall back: 02:30 happens twice
   croniter: Sat 2027-10-30 02:30 CEST | Sun 2027-10-31 02:30 CEST | Sun 2027-10-31 02:30 CET | Mon 2027-11-01 02:30 CET | Tue 2027-11-02 02:30 CET
   robfig:   Sat 2027-10-30 02:30 CEST | Sun 2027-10-31 02:30 CEST | Sun 2027-10-31 02:30 CET | Mon 2027-11-01 02:30 CET | Tue 2027-11-02 02:30 CET
Enter fullscreen mode Exit fullscreen mode

In spring, croniter moved the run to 03:00, but robfig skipped 28 March entirely: Saturday, then Monday. GitHub's docs describe the croniter behaviour for their timezone: option (a 2:30 AM schedule "advances to 3:00 AM"). In autumn, both libraries ran the job twice, an hour apart. A nightly billing or backup job is exactly the kind of job you don't want to skip or run twice.

The Kubernetes row is my inference from the library, not a cluster test: with .spec.timeZone set, the controller uses this parser to compute the next run. Classic Linux cron daemons have their own DST rules, which I didn't test.

The simple fix: don't schedule jobs between 01:00 and 03:00 local time in a zone with daylight saving time, or schedule them in UTC.

And a few ways a job doesn't run at all

These come from the docs, not from my tests:

  • GitHub Actions: the shortest interval is once every 5 minutes. Scheduled runs "can be delayed during periods of high loads", the start of every hour is named as a busy time, and "some queued jobs may be dropped". In a public repository, scheduled workflows are disabled after 60 days without repository activity. Avoid minute 0.
  • Kubernetes: if the controller missed more than 100 schedules, it logs a TooManyMissedTimes warning and starts only the most recent one. A startingDeadlineSeconds below 10 may mean the job isn't scheduled at all, because the controller checks every 10 seconds. The docs also say a CronJob can occasionally create two Jobs or none, so jobs should be idempotent.
  • Cloudflare: a new or changed trigger can take up to 15 minutes to propagate, and runs can be missed until it does.

Syntax also travels badly. Cloudflare accepts L, W and # (last day, nearest weekday, "first Monday"). Neither library accepted all of them in my test:

"0 0 L * *": croniter -> Mon 2026-11-30 00:00 UTC | Thu 2026-12-31 00:00 UTC
             robfig   -> ERROR: failed to parse int from L: strconv.Atoi: parsing "L": invalid syntax
"0 18 * * 5L": croniter -> ERROR: [0 18 * * 5l] is not acceptable
               robfig   -> ERROR: failed to parse int from 5L: strconv.Atoi: parsing "5L": invalid syntax
"0 9 * * 1#1": croniter -> Mon 2026-12-07 09:00 UTC | Mon 2027-01-04 09:00 UTC
               robfig   -> ERROR: failed to parse int from 1#1: strconv.Atoi: parsing "1#1": invalid syntax
Enter fullscreen mode Exit fullscreen mode

A line that's valid on Cloudflare fails to parse on Kubernetes, and a line that works in croniter can still be rejected by the cluster.

A checklist before you move a cron line

  1. Write the zone next to the line, in a comment or in the platform's zone field. Never let "09:00" mean whatever the machine thinks.
  2. Use day names (MON-FRI), never numbers, if the line could ever end up on Cloudflare.
  3. Never set both day fields unless you really want OR. Filter the rest in code.
  4. Use steps that divide the range, or list the times.
  5. Keep jobs out of 01:00-03:00 local time, or schedule in UTC.
  6. Make every job idempotent, and avoid minute 0 on shared schedulers.
  7. Print the next 5-10 runs with the library your platform actually uses before you deploy. A short version of the script I used is below.
import datetime as dt
from zoneinfo import ZoneInfo
from croniter import croniter

def next_runs(expr, tz, start, n=5):
    t = dt.datetime.fromisoformat(start).replace(tzinfo=ZoneInfo(tz))
    it = croniter(expr, t)
    return [it.get_next(dt.datetime).strftime('%a %Y-%m-%d %H:%M %Z') for _ in range(n)]

print(next_runs('30 2 * * *', 'Europe/Berlin', '2027-03-26T12:00'))
Enter fullscreen mode Exit fullscreen mode

For a quick visual check of simple schedules, the Cron Expression Generator lists the next runs in your browser's time zone, and its guide explains each field. If the job runs against timestamps, the Unix Timestamp converter helps check what "09:00 UTC" is in epoch seconds. More free tools are on findutils.com.

What this doesn't test

  • Real platform runs. No jobs ran on GitHub, a Kubernetes cluster or Cloudflare. Platform behaviour is quoted from their docs as of 29 November 2026.
  • Classic cron daemons (Vixie cron, cronie) and other schedulers like GitLab, AWS EventBridge or systemd timers.
  • Day-of-month/day-of-week OR on Cloudflare. Their docs don't say, and I couldn't test it.

Need help with a project? The team behind FindUtils takes on freelance work on Upwork, including PHP bug fixes, a PHP 8 upgrade or new features for your website, for example moving an old PHP site's cron jobs to a new host without changing when they run.

Top comments (1)

Collapse
 
c-wind profile image
c-wind •

The Cloudflare 1=Sunday vs everyone else's 0=Sunday trap is the one I'd have missed. Same 0 9 * * 1 looks obviously "Monday morning" until it silently runs on Sunday in a Worker.

One thing that jumped out from the DST section: if Kubernetes is really following robfig and skipping the spring-forward 02:30 entirely, then a job you thought was "daily" has a hole once a year, while the same line in Actions (croniter-like, shifted to 03:00) still fires. That's worse than running twice in the fall, because the miss leaves no log line to notice. Staying out of 01:00–03:00, or just scheduling in UTC as you suggest, seems like the only reliable fix.

Also appreciated the note that a robfig library test accepting CRON_TZ=Europe/Berlin ... doesn't mean CronJob will — Kubernetes will reject the prefix in .spec.schedule. Easy to cargo-cult from a passing Go test.