Home › Guides › Cron Syntax

Cron Expression Syntax, Explained with Examples

A cron expression is five fields separated by spaces that tell a scheduler when to run a job. Once you know what each field means and how the four special characters work, you can read almost any schedule. This guide covers the syntax, a table of common schedules, the rule that surprises most people, and how cron differs in Kubernetes, GitHub Actions and other platforms. To check an expression as you read, paste it into CronLens, which explains it in plain English and lists the next 10 run times.

The five fields

┌───────────── minute        (0–59)
│ ┌─────────── hour          (0–23)
│ │ ┌───────── day of month  (1–31)
│ │ │ ┌─────── month         (1–12 or JAN–DEC)
│ │ │ │ ┌───── day of week   (0–6, Sunday = 0; 7 is also Sunday in most crons; or SUN–SAT)
│ │ │ │ │
* * * * *  command

Hours use the 24-hour clock, so 0 14 * * * is 2:00 PM. A job runs when the current time matches every field.

The special characters

CharacterMeaningExample
*Every value* * * * * runs every minute
,A list0 9,17 * * * runs at 9:00 and 17:00
-A range0 9 * * 1-5 runs at 9:00 Monday to Friday
/A step*/15 * * * * runs at minutes 0, 15, 30 and 45

Steps start from the beginning of the range, not from when the job was added. */7 * * * * runs at minutes 0, 7, 14 … 56, then again at 0, so the gap between 56 and 0 is only 4 minutes. If you need an exact interval that doesn't divide 60 evenly, cron is the wrong tool; use a loop with a sleep or a scheduler that supports intervals.

Common schedules

ExpressionRuns
*/5 * * * *Every 5 minutes
0 * * * *Every hour, on the hour
0 */6 * * *Every 6 hours (00:00, 06:00, 12:00, 18:00)
0 0 * * *Every day at midnight
30 2 * * *Every day at 2:30 AM
0 9 * * 1-5Weekdays at 9:00 AM
0 0 * * 0Every Sunday at midnight
0 0 1 * *The first day of every month at midnight
0 0 1 1 *Once a year, January 1 at midnight
15 10 * * 1Mondays at 10:15 AM

The day-of-month / day-of-week trap

This is the rule that catches most people. When both day of month and day of week are restricted (neither is *), standard cron runs the job when either one matches, not when both do.

0 9 13 * 5

This does not mean "Friday the 13th at 9:00". It means "at 9:00 on the 13th of every month, and also every Friday". There is no way to say "only when both match" in standard 5-field cron. The usual workaround is to schedule on one field and check the other in the command:

0 9 13 * * [ "$(date +\%u)" = 5 ] && /path/to/job.sh

Note the \%. In a crontab line, a bare % is turned into a newline and everything after it is sent to the command's standard input, so it has to be escaped. That breaks many date +%Y-%m-%d commands the first time someone puts them in a crontab.

Time zones

Classic cron runs in the time zone of the machine (or container) it runs on, which is often UTC on servers. Two consequences:

  • A job set for 0 9 * * * on a UTC server runs at 9:00 UTC, which may be the middle of the night where you are.
  • Where the system clock follows daylight saving time, a job scheduled during the skipped hour may not run that day, and one in the repeated hour may run twice, depending on the cron implementation. Scheduling outside roughly 1:00–3:00 local time avoids the question.

CronLens shows the next run times in your browser's local time zone and labels it, so you can see the difference between "9:00 on the server" and "9:00 for you". The Unix timestamp converter helps when logs record run times as epoch seconds.

Cron on different platforms

PlatformFormatThings to know
Linux crontab (Vixie cron, cronie)5 fieldsAlso accepts shortcuts like @daily, @hourly and @reboot. Runs with a minimal environment: set PATH or use full paths.
Kubernetes CronJob5 fieldsUses the controller's time zone unless you set spec.timeZone (for example "America/New_York").
GitHub Actions schedule5 fieldsAlways UTC. The shortest interval is every 5 minutes, and runs can be delayed when GitHub is busy, especially at the top of the hour.
Quartz (Java), Spring @Scheduled6–7 fieldsAdds a seconds field at the start (Quartz also allows an optional year at the end). Quartz uses ? in one of the two day fields to mean "no specific value".
AWS EventBridge6 fieldsWritten as cron(...), adds a year field, and one of the day fields must be ?. Day of week runs 1–7 with Sunday = 1.

Because the 6-field formats shift every field one place to the right, pasting a Quartz expression into crontab (or the reverse) gives a completely different schedule without an error. CronLens reads standard 5-field cron, the format used by crontab, Kubernetes and most CI systems.

Checklist when a cron job doesn't run

  1. Paste the expression into CronLens and confirm the next run times are what you expect.
  2. Check the server's time zone (date or timedatectl).
  3. Use absolute paths for the command and any files it reads. Cron doesn't load your shell profile.
  4. Escape every % in the command.
  5. Send output somewhere you can read: >> /var/log/myjob.log 2>&1.
  6. Make sure the crontab ends with a newline. Some cron versions ignore a last line without one.

Related tools

  • CronLens: cron expression to plain English, with the next 10 runs.
  • UnixTime: convert epoch timestamps from logs to dates and back.

References