Developer

Cron Expressions Explained: Fields, Symbols and 15 Real Examples

Five fields, four symbols and a handful of traps. Learn to read and write cron schedules, see 15 worked examples, and find out why a job set for Friday the 13th runs every Friday.

Cron Expressions Explained: Fields, Symbols and 15 Real Examples
Photo by Suhas Hanjar on Pexels

Key takeaways

  • A cron schedule is five fields in a fixed order: minute, hour, day of month, month, day of week; an asterisk means every value.
  • Commas list values, a hyphen gives a range and a slash gives a step, so */15 9-17 * * 1-5 means every quarter hour during office hours on weekdays.
  • When both day of month and day of week are set, classic cron runs the job if either matches, not both.
  • Cron runs in the system time zone, so a job set for 01:30 local can be skipped in spring and run twice in autumn; schedule in UTC where you can.
  • Flavours differ: Quartz and Spring add a seconds field, AWS adds a year, and GitHub Actions runs in UTC with a five-minute minimum.

A cron expression is five space-separated fields that describe when a job should run: minute, hour, day of month, month and day of week. 0 9 * * 1-5 means 09:00 every weekday. An asterisk means every possible value, a comma lists values, a hyphen gives a range and a slash gives a step. That is the whole language, yet schedules still go wrong, because the day-of-month and day-of-week fields combine in an unexpected way, because cron runs on local time that jumps twice a year, and because different schedulers read the same string differently. This guide covers the syntax, 15 real schedules, the traps and how to test before you trust a job to run at 03:00.

The five fields

The order never changes, and every field must be present.

PositionFieldAllowed valuesNotes
1Minute0 to 59
2Hour0 to 2324-hour clock; 0 is midnight
3Day of month1 to 31Days that do not exist in a month are skipped
4Month1 to 12 or JAN to DECNames are case-insensitive
5Day of week0 to 7 or SUN to SAT0 and 7 are both Sunday in most Linux crons

After the five fields comes the command. In a crontab line the two are separated by whitespace:

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

Read a schedule from left to right as "at minute 30, of hour 2, on every day of the month, in every month, on every day of the week": 02:30 every day. Reading it aloud like that catches most mistakes, particularly swapped minute and hour fields, which turn "02:30 daily" into "every day at 30:02", an error some crons reject and others quietly misinterpret.

The four special characters

Asterisk: every value

* in a field matches all of that field's values. * * * * * is every minute of every day. An asterisk in the minute field with a number in the hour field, * 9 * * *, runs sixty times between 09:00 and 09:59, which is almost never what was intended; 0 9 * * * is once at 09:00.

Comma: a list

0 9,13,17 * * * runs at 09:00, 13:00 and 17:00. There are no spaces inside a list, because a space would start the next field. Lists can mix numbers and ranges: 0 9 * * 1,3,5 is Monday, Wednesday and Friday.

Hyphen: a range

0 9-17 * * * is on the hour from 09:00 to 17:00 inclusive, nine runs a day. 0 9 * * 1-5 is Monday to Friday. Ranges that wrap, such as 22-2 in the hour field, are not supported by classic cron; write 22,23,0,1,2 instead.

Slash: a step

*/15 * * * * is every 15 minutes: at 0, 15, 30 and 45 past each hour. The step counts from the start of the range, so */15 is shorthand for 0-59/15, and 5-59/15 starts at 5 and gives 5, 20, 35, 50. A step applies to the field, not to elapsed time, which matters when the field length is not a multiple of the step. 0 */5 * * * runs at 00:00, 05:00, 10:00, 15:00 and 20:00 and then again at 00:00, so the last gap is four hours, not five. In the same way 0 0 */2 * * runs on the 1st, 3rd, 5th and so on, and in a 31-day month runs on both the 31st and the 1st.

Many crons accept shortcuts: @hourly, @daily (midnight), @weekly (Sunday midnight), @monthly, @yearly and @reboot. They are readable in a crontab but are not understood by every scheduler, so stick to the five-field form in anything portable.

15 real-world schedules

ExpressionPlain EnglishTypical use
* * * * *Every minuteQueue workers, health checks
*/5 * * * *Every 5 minutesPolling an API, syncing a cache
0 * * * *Every hour, on the hourRolling up metrics
30 2 * * *02:30 every dayNightly backups
0 9 * * 1-509:00 Monday to FridayMorning reports
0 9,17 * * 1-509:00 and 17:00 on weekdaysStart- and end-of-day jobs
*/15 9-17 * * 1-5Every 15 minutes from 09:00 to 17:45 on weekdaysOffice-hours polling
0 */6 * * *00:00, 06:00, 12:00 and 18:00Four-times-daily imports
0 0 * * 0Midnight every SundayWeekly clean-up
0 3 * * 603:00 every SaturdayFull database export
0 0 1 * *Midnight on the first of every monthMonthly invoices
15 14 1 * *14:15 on the first of every monthMonthly reminder email
0 0 1 1 *Midnight on 1 JanuaryYearly archive
0 8 * * 108:00 every MondayWeekly summary
0 22 * * 1-522:00 on weekdaysLog rotation before the night batch

Two of these hide a subtlety. */15 9-17 includes 17:15, 17:30 and 17:45, because the hour range runs to the end of hour 17; if the last run should be 17:00, use 0 17 as a separate entry or stop the range at 16. And 0 0 1 * * is safe, but 0 0 31 * * would run only in the seven months that have a 31st, and 0 0 30 * * never runs in February. "Last day of the month" has no direct spelling in classic cron, covered below.

The day-of-month versus day-of-week trap

This is the mistake that reaches production most often. When both the day-of-month and day-of-week fields are restricted (neither is *), classic cron runs the job when either matches, not when both do. The POSIX specification says so explicitly, and Vixie cron, cronie and busybox all follow it.

0 9 13 * 5 looks like "09:00 on Friday the 13th". It actually runs at 09:00 on the 13th of every month and at 09:00 every Friday. Likewise 0 9 1-7 * 1, an attempt at "first Monday of the month", runs on the first seven days of every month and on every Monday.

The fix in classic cron is to restrict one field in the expression and check the other in the command. Inside a crontab a percent sign must be escaped as \%, because an unescaped one is treated as a newline:

0 9 * * 1 [ "$(date +\%d)" -le 7 ] && /opt/jobs/first-monday.sh

That runs every Monday at 09:00 and exits immediately unless the date is the 1st to the 7th, which is exactly the first Monday. The same trick gives "last day of the month":

0 23 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /opt/jobs/month-end.sh

Schedulers built on Quartz, including Spring and many Java systems, solve this differently: they require one of the two fields to be ? (no specific value) and add L for last, W for nearest weekday and # for the nth weekday, so the first Monday becomes 0 0 9 ? * MON#1. The expressions are not interchangeable, which is why the flavour table at the end matters.

A paper calendar pinned to a wall with dates circled
Photo by Towfiqu barbhuiya on Pexels

Time zones and daylight saving

Cron compares the schedule with the system clock in the system's time zone. A server set to Europe/London runs 0 9 * * * at 09:00 London time, which is 09:00 UTC in winter and 08:00 UTC in summer. If a colleague in Berlin or a downstream system in UTC expects the job at a fixed instant, it drifts by an hour twice a year.

The two daylight saving transitions each break a window of schedules. When clocks go forward, an hour of local time does not exist: in the United Kingdom on 29 March 2026 the clock goes from 00:59 to 02:00, so 30 1 * * * has no 01:30 to run at. When clocks go back on 25 October 2026, 01:00 to 01:59 happens twice, and the same schedule can run twice. Implementations differ on what they do: Vixie cron and cronie try to run skipped jobs once after a forward jump and avoid repeats after a backward one, but only for jobs that name a specific hour and minute, while simpler crons in containers or embedded systems just follow the clock. Do not rely on either behaviour.

Three practical rules avoid the whole problem:

  • Run the scheduler in UTC. UTC has no daylight saving, so every schedule means the same instant all year. Most Linux distributions default to UTC on servers; check with timedatectl or date.
  • If a job must follow local time, such as a report that lands at 09:00 for staff in one country, set the zone per job rather than per server. cronie supports a CRON_TZ=Europe/London line in the crontab; Kubernetes CronJobs have a timeZone field; systemd timers accept a zone in OnCalendar.
  • Keep jobs out of the 01:00 to 03:00 local window on transition days, or out of that window entirely, since it costs nothing to run a backup at 03:30 instead.

When you need to know what a UTC schedule means for a particular person, the Time Zone Converter resolves a date and time between named zones with the correct offset for that date, including the weeks when Europe and North America are out of step.

A weekly schedule on a whiteboard
Photo by RDNE Stock project on Pexels

Testing a schedule before you trust it

A wrong schedule that runs a report at 03:00 instead of 15:00 is a nuisance. A wrong schedule that runs a deletion job every minute is a disaster. Test in this order.

  1. Read back the next runs. Paste the expression into the Cron Expression Generator, which explains it in words and lists the next run times. If the list shows Fridays when you asked for the 13th, you have found the day-of-week trap before it found you.
  2. Check the instant, not just the local time. Where a job feeds a system in another zone, take a next-run time, convert it to an epoch value with the Unix Timestamp Converter and compare it with what the other side expects. Two systems that agree on 1793091600 agree on the moment; two that agree on "09:00" may not.
  3. Dry-run the command by hand as the same user, from a minimal environment: env -i /bin/sh -c '/opt/jobs/report.sh'. Cron does not load your shell profile, its PATH is short and HOME may differ, so a script that works at the prompt can fail under cron because python or node is not found. Use absolute paths inside the script.
  4. Schedule a run two minutes ahead with a harmless command such as date >> /tmp/cron-test.log, wait, and confirm the line appears. This proves the crontab is installed, the daemon is running and the syntax is accepted.
  5. Capture output. Append >> /var/log/job.log 2>&1 to the command, or set MAILTO so errors reach a mailbox someone reads. A silent failure at 03:00 is the default without this.
  6. Prevent overlap. A five-minute job that sometimes takes six minutes will stack up. Wrap it in flock -n /tmp/job.lock /opt/jobs/sync.sh so a run that finds the previous one still going exits instead.
  7. Check the first real run in the log the next morning, and again after the next daylight saving change.

Example. A team schedules 0 2 * * * for a nightly export on a server set to Europe/London. A partner in New York collects the file at 21:30 their time. For most of the year 02:00 London is 21:00 in New York, so the file is ready with half an hour to spare. For three weeks from 8 March 2026 and one week from 25 October, the gap between the two cities is four hours rather than five, so the export starts at 22:00 New York, after the pickup, and the partner silently receives the previous day's file. Moving the job to 0 1 * * * under CRON_TZ=UTC makes it 20:00 or 21:00 in New York all year, always before the pickup.

Differences between cron flavours

The five-field form is the common core, but the systems you meet in practice extend or restrict it. Check which one you are writing for before copying an expression between them.

FlavourFieldsDay of weekNotable differences
Vixie cron, cronie (Linux crontab)50-7, 0 and 7 are Sunday@daily shortcuts, CRON_TZ in cronie, % means newline, day fields combine with OR
Quartz (Java)6 or 7: seconds first, optional year1-7, 1 is SundayRequires ? in one of the day fields; supports L, W, #
Spring @Scheduled6: seconds first0-7, 0 and 7 are SundaySupports L, # and W since Spring 5.3; separate zone attribute
Kubernetes CronJob50-6timeZone field; startingDeadlineSeconds controls missed runs
GitHub Actions50-6Always UTC; minimum interval 5 minutes; runs may be delayed in busy periods; no @ shortcuts
AWS EventBridge6: adds year at the end1-7 or SUN-SATUTC only; one of the two day fields must be ?; supports L, W, #
Jenkins50-7H picks a stable random value to spread load, as in H 2 * * *
systemd timersNot cron syntaxOnCalendar=Mon..Fri 09:00 style; systemd-analyze calendar previews next runs

The seconds field is the most common source of confusion when moving between flavours. 0 9 * * 1-5 in a crontab means 09:00 on weekdays; pasted into a Quartz or Spring scheduler, the same five values are read as second 0, minute 9, every hour, every day, and a day-of-week of 1-5, which in Quartz is Sunday to Thursday. The job runs at nine minutes past every hour on the wrong days. Add the leading 0 for seconds and check the day numbering, and always let the scheduler print its own interpretation of the schedule before deploying it.

Where to go next

Build or decode any schedule with the Cron Expression Generator, which explains an expression in plain English and lists upcoming run times. When a schedule crosses zones, use the Time Zone Converter to see what a UTC time means locally on a given date, and the Unix Timestamp Converter to pin a run to an exact instant when comparing logs from different systems.

Related guides: Unix timestamps and time zones for developers.

Frequently asked questions

What does * * * * * mean in cron?

Every minute of every hour, every day. Each asterisk stands for all allowed values in its field: minute, hour, day of month, month and day of week. It is the most frequent schedule cron can express and is used for queue workers and health checks. If you want once an hour rather than every minute, set the minute field to a number, such as 0 * * * * for the top of each hour.

How do I run a cron job every 5 minutes?

Use */5 * * * * followed by the command. The slash means a step through the minute field, so the job runs at 0, 5, 10 and so on up to 55 minutes past each hour. To start at a different offset, write a range before the slash, such as 2-59/5, which gives 2, 7, 12 and onwards. For every five minutes during working hours only, add an hour range: */5 9-17 * * 1-5.

Why does my cron job run on the wrong days?

Most likely both the day-of-month and day-of-week fields are set. Classic cron treats that as either-or: 0 9 13 * 5 runs on every 13th and on every Friday, not only on Friday the 13th. Restrict one field in the expression and test the other inside the command with date. Another cause is the flavour: Quartz numbers Sunday as 1, while Linux cron uses 0 or 7.

Does cron use UTC or local time?

Cron uses the time zone of the system it runs on, which may be UTC on a server or local time on a laptop or a container with an explicit zone. That means schedules shift by an hour at daylight saving changes and jobs in the skipped or repeated hour may be missed or doubled. Running the scheduler in UTC, or setting CRON_TZ per job where supported, keeps the schedule tied to a fixed instant.

How can I run a cron job on the last day of the month?

Classic cron has no last-day symbol, so schedule the job on days 28 to 31 and let the command check whether tomorrow is the 1st, for example 0 23 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && your-command, remembering that the percent sign must be escaped in a crontab. Quartz, Spring and AWS EventBridge support L in the day-of-month field, so 0 0 23 L * ? does the same job there.

Why does my script work in the terminal but not from cron?

Cron runs commands without your shell profile, with a minimal PATH and sometimes a different HOME, so anything that depends on environment variables, relative paths or tools found via PATH can fail. Use absolute paths for commands and files, set any variables at the top of the crontab or inside the script, and redirect output to a log file with 2>&1 so you can see the error message cron would otherwise discard.

Try the tools from this guide

Keep reading

Related guides

All guides