Cron examples

Ready-made cron expressions for the schedules people need most, each explained field by field, with the equivalent for Quartz, AWS EventBridge, GitHub Actions and Kubernetes.

Common cron expressions

ExpressionRuns
* * * * *Every minute
*/5 * * * *Every 5 minutes
*/10 * * * *Every 10 minutes
*/15 * * * *Every 15 minutes
*/30 * * * *Every 30 minutes
0 * * * *Every hour, on the hour
15 * * * *Every hour at quarter past
0 */2 * * *Every 2 hours
0 */6 * * *Every 6 hours
0 9-17 * * *Every hour from 09:00 to 17:00
0 0 * * *Every day at midnight
30 6 * * *Every day at 06:30
0 0,12 * * *Twice a day, at midnight and noon
0 9 * * 1-5Weekdays at 09:00
0 18 * * 5Fridays at 18:00
0 0 * * 0Every Sunday at midnight
0 0 * * 6,0Saturdays and Sundays at midnight
0 0 1 * *First day of every month
0 0 15 * *The 15th of every month
0 0 28-31 * *Days 28 to 31 (the basis for "last day of month")
0 0 1 */3 *First day of every quarter
0 0 1 1 *Once a year, on 1 January

Paste any of them into the cron expression explainer to see the next run times in your own time zone.

Schedules explained in detail

Schedules

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 or SUN-SAT (0 and 7 are both Sunday)
│ │ │ │ │
* * * * *  command
  • * any value
  • a,b a list: 0,30 is minutes 0 and 30
  • a-b a range: 1-5 is Monday to Friday
  • */n every nth value counting from the start of the field: */15 in the minute field is 0, 15, 30, 45
  • a-b/n every nth value inside a range: 9-17/2 is 9, 11, 13, 15, 17

Steps restart with each hour, day or month. */7 in the minute field runs at 0, 7, … 56 and then again at 0, four minutes later, not seven. A true "every 7 minutes" cannot be written in cron.

If both the day-of-month and day-of-week fields are restricted, the job runs when either matches: 0 0 13 * 5 is every 13th and every Friday, not Friday the 13th.

How the syntaxes differ

SchedulerFieldsTime zoneDifferences from Unix cron
Unix cron (crontab)5System local time; some versions accept CRON_TZ=Also has @hourly, @daily, @weekly, @monthly, @yearly and @reboot
Kubernetes CronJob5The controller's zone, usually UTC; set spec.timeZone to change itSame syntax, including the @ shortcuts except @reboot
GitHub Actions5UTC onlyShortest interval is 5 minutes; runs can start late, or be dropped, when the service is busy
Quartz6 or 7: seconds first, optional year lastThe JVM's, or one set on the triggerWeekdays are 1-7 from Sunday; one day field must be ?; adds L, W and #
AWS EventBridge6: year last, wrapped in cron( )UTC for rules; EventBridge Scheduler takes a time zoneWeekdays are 1-7 from Sunday; one day field must be ?; adds L, W and #; also has rate(5 minutes)

The weekday numbering is the trap when copying between them: 1 is Monday in Unix cron and Sunday in Quartz and AWS. Three-letter names (MON-FRI) mean the same everywhere, so the converted expressions on these pages use names. Spring's @Scheduled(cron = …) takes six fields like Quartz but numbers weekdays 0-7 like Unix cron, and does not require ?.

Before you rely on a schedule

  • Time zone. Servers are often on UTC. 0 9 * * * on a UTC server is 10:00 or 11:00 in Berlin depending on the season.
  • Daylight saving time. A job set for a local time that is skipped or repeated when the clocks change may not run, or may run twice, depending on the cron implementation. Keep jobs out of the 01:00 to 03:00 window, or run the machine in UTC.
  • Overlap. Cron starts a new run whether or not the last one finished. Use a lock such as flock -n /tmp/job.lock command, or concurrencyPolicy: Forbid in Kubernetes.
  • Environment. Cron runs with a minimal PATH and no shell profile. Use full paths, and redirect output to a log: >> /var/log/job.log 2>&1.
  • Percent signs. In a crontab, an unescaped % in the command ends the command and starts its standard input. Write \%, as in date +\%F.

Questions

What do the five stars in a cron expression mean?

Minute, hour, day of month, month and day of week, in that order. A star means "every value", so * * * * * runs every minute.

Is 0 or 1 Monday in cron?

In Unix cron, Kubernetes and GitHub Actions, 0 is Sunday and 1 is Monday (7 is also Sunday). In Quartz and AWS EventBridge, 1 is Sunday and 2 is Monday. Names such as MON avoid the difference.

Can cron run a job every 45 minutes or every 90 minutes?

Not with one expression, because steps restart at the top of each hour or day. Run the job more often and let the script decide whether enough time has passed, or use a scheduler with interval support such as a systemd timer.