Skip to content

Menu

Cron Cheat Sheet: Crontab Syntax, systemd Timers, Kubernetes and GitHub Actions

Checked against cron (cronie), systemd timers, Kubernetes CronJob, GitHub Actions cronie crontab(5), systemd 262, Kubernetes 1.37 docs, GitHub Actions docs on 28 November 2026. Each section links to the official docs it was checked against.

This is for anyone who has to schedule a job and wants to get the five fields right the first time, then move the same schedule to a systemd timer, a Kubernetes CronJob or a GitHub Actions workflow. Crontab rows follow cronie's crontab(5) man page, which is what most Linux distributions ship. Nothing here could be run on the day: there is no systemd-analyze on the machine used, so every row is marked as checked against the docs only.

When to use what

Plain crontab is fine for a single server and a job that can silently miss a run when the machine is off. Move to a systemd timer when you want logs in journald, Persistent=true to catch up on missed runs, or tighter timing than the one-minute AccuracySec default; OnCalendar also reads better (Mon..Fri 09:00) than five cryptic fields. In a cluster, use a Kubernetes CronJob and always set timeZone and concurrencyPolicy, because the defaults (controller's local zone, Allow) surprise people. GitHub Actions schedules are for repo chores like stale-issue sweeps and nightly builds, not for anything that must run on the minute: runs get delayed at busy times and can even be dropped.

If you are unsure what an expression means, paste it into the crontab translator or the cron parser before you ship it, and build new ones with the crontab generator. The cron expressions guide and our cron jobs best practices post go deeper on locking and logging.

System files (/etc/crontab, /etc/cron.d/*) add a user name between the time fields and the command.

m h dom mon dow command

Field order: minute 0-59, hour 0-23, day of month 1-31, month 1-12, weekday 0-7

Try it: crontab-translatorFrom the docs, not run by us
0 or 7 in day of week

Both mean Sunday, so 1-5 is Monday to Friday

From the docs, not run by us
jan-mar mon,wed,fri

Use three-letter month and weekday names, case-insensitive, in ranges and lists

From the docs, not run by us
30 2 * * * root /usr/local/bin/backup.sh

Line format for /etc/crontab and /etc/cron.d files: user name before the command

From the docs, not run by us
* * * * *

Every field spans first to last, so the job runs once a minute

From the docs, not run by us
*/15 * * * *

Run every 15 minutes, at :00, :15, :30 and :45

Try it: Crontab GeneratorFrom the docs, not run by us
0 9-17 * * 1-5

Run on the hour from 09:00 to 17:00, Monday to Friday

From the docs, not run by us
0 0-23/2 * * *

Run every two hours starting at midnight

From the docs, not run by us
30 4 1,15 * *

Run at 04:30 on the 1st and 15th of each month

From the docs, not run by us
*/35 * * * *

Runs at :00 and :35, not every 35 minutes: steps reset each hour

From the docs, not run by us
6~15 * * * *

cronie only: pick a random minute between 6 and 15 when the crontab loads

From the docs, not run by us
@reboot

Run once when the cron daemon starts after boot

From the docs, not run by us
@daily (@midnight)

Same as 0 0 * * *; @midnight is accepted by Kubernetes, not listed in cronie

From the docs, not run by us
@hourly

Same as 0 * * * *

From the docs, not run by us
@weekly

Same as 0 0 * * 0, midnight going into Sunday

From the docs, not run by us
@monthly @yearly @annually

Midnight on the 1st of the month, or on 1 January

From the docs, not run by us

If both day fields are restricted, cron fires when either matches. There is no AND in standard cron.

30 4 1,15 * 5

Runs on the 1st, the 15th and every Friday, not only Fridays that fall on those dates

Try it: Cron ParserFrom the docs, not run by us
0 9 * * 5

Every Friday at 09:00; leaving day of month as * makes the weekday field decide alone

From the docs, not run by us
0 9 1-7 * * [ "$(date +\%u)" = 1 ] && cmd

First Monday of the month: restrict the dates, then test the weekday in the shell

From the docs, not run by us

Mail each job's output to this address instead of the crontab owner

From the docs, not run by us
MAILTO=""

Send no mail at all; pair it with your own logging

From the docs, not run by us
SHELL=/bin/bash

Run commands with bash instead of the default /bin/sh

From the docs, not run by us
PATH=/usr/local/bin:/usr/bin:/bin

Cron only sets SHELL, LOGNAME and HOME for you; define PATH and anything else in the crontab

From the docs, not run by us
CRON_TZ=Europe/Berlin

cronie: read the schedule in this time zone instead of the system zone

From the docs, not run by us
date +\%F

Escape % with a backslash; an unescaped % ends the command and starts stdin

From the docs, not run by us

Check any expression with systemd-analyze calendar "<expr>", which prints the normalized form and the next run.

OnCalendar=*:0/15

Every 15 minutes, like /15 * * *

Try it: systemd-unit-generatorFrom the docs, not run by us
OnCalendar=Mon..Fri 09:00

Weekdays at 09:00, like 0 9 * * 1-5; .. marks a range

From the docs, not run by us
OnCalendar=daily

Normalizes to --* 00:00:00; hourly, weekly, monthly, quarterly and semiannually also exist

From the docs, not run by us
OnCalendar=*-*~01

The last day of every month, which plain cron cannot express

From the docs, not run by us
OnCalendar=Mon *-05~07/1

The last Monday in May

From the docs, not run by us
OnCalendar=weekly Pacific/Auckland

Add an IANA zone at the end to schedule in that zone

From the docs, not run by us
timeZone: "Etc/UTC"

Pin the schedule zone; without it the controller manager's local zone is used

From the docs, not run by us
concurrencyPolicy: Forbid

Skip a run while the previous Job is still running; Replace cancels it, Allow is the default

From the docs, not run by us
startingDeadlineSeconds: 200

Skip a run that could not start within 200 seconds of its scheduled time

From the docs, not run by us
successfulJobsHistoryLimit: 3

Keep 3 finished Jobs (the default); failedJobsHistoryLimit defaults to 1

From the docs, not run by us
on: schedule: - cron: "17 3 * * *"

Run nightly at 03:17; an off-peak minute is less likely to be delayed

Try it: github-actions-generatorFrom the docs, not run by us
timezone: "America/New_York"

Set next to cron to schedule in a local zone; the default is UTC

From the docs, not run by us
*/5 * * * *

The shortest interval GitHub allows is every 5 minutes

From the docs, not run by us
github.event.schedule

Tells you which of several cron entries started the run

From the docs, not run by us
@daily

Not supported in Actions: write the five fields instead

From the docs, not run by us

Worked example: Move a nightly backup from crontab to a systemd timer

The crontab line runs a backup at 02:30 every night and mails nothing:

MAILTO=""
30 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1

The timer version adds catch-up after downtime and journald logs:

# /etc/systemd/system/backup.timer
[Timer]
OnCalendar=*-*-* 02:30:00
Persistent=true

[Install]
WantedBy=timers.target
systemctl daemon-reload
systemctl enable --now backup.timer
systemd-analyze calendar "*-*-* 02:30:00"

With no Unit= line, the timer starts backup.service, the unit with the same base name, so create that service to run the script. The last command prints the normalized expression and the next time it will fire, so you can confirm it reads 02:30 in the zone you expect before trusting it. Persistent=true is the real gain: if the server was off at 02:30, the job runs at the next boot, where cron would simply skip that night. Not run here, because systemd-analyze was not available; check the output on your own host.

Common mistakes

  • Writing 0 9 1 * 1 and expecting it to run only when the 1st is a Monday.

    Cron ORs the two day fields, so this runs on every 1st and every Monday. Keep one day field as * and test the other condition in the shell.

  • A script works in your terminal but fails under cron with "command not found".

    Cron uses a minimal environment. Set PATH at the top of the crontab or call every program by its full path.

  • Using date +%Y-%m-%d inside a crontab line and getting a truncated command.

    Escape each percent sign as \% or move the command into a script file.

  • Using /35 or /90 in the minute field and expecting a 35 or 90 minute interval.

    Steps restart every hour. Use a systemd timer with OnUnitActiveSec, or run every 5 minutes and check elapsed time in the script.

  • Putting CRON_TZ= in a Kubernetes schedule string to change its zone.

    Kubernetes rejects it. Set spec.timeZone to an IANA name like Europe/London instead.

  • Relying on a GitHub Actions schedule in a quiet public repo for months.

    Scheduled workflows are disabled after 60 days without repository activity. Re-enable them in the Actions tab or keep the repo active.