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
| Expression | Runs |
|---|---|
* * * * * | 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-5 | Weekdays at 09:00 |
0 18 * * 5 | Fridays at 18:00 |
0 0 * * 0 | Every Sunday at midnight |
0 0 * * 6,0 | Saturdays 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
- Every 5 minutes*/5 * * * *: every 5 minutes
- Every 15 minutes*/15 * * * *: every 15 minutes
- Every hour0 * * * *: every hour, on the hour
- Every 2 hours0 */2 * * *: every 2 hours, on even hours
- Every day at midnight0 0 * * *: every day at 00:00
- Twice a day0 0,12 * * *: at midnight and noon
- Every weekday at 9am0 9 * * 1-5: at 09:00, Monday to Friday
- Every Sunday0 0 * * 0: every Sunday at 00:00
- First day of the month0 0 1 * *: at 00:00 on the 1st of each month
- Last day of the month0 0 28-31 * *: days 28–31, with a test for the last day
- Every 30 seconds* * * * *: every minute is the limit; use sleep 30 or a systemd timer
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 valuea,ba list:0,30is minutes 0 and 30a-ba range:1-5is Monday to Friday*/nevery nth value counting from the start of the field:*/15in the minute field is 0, 15, 30, 45a-b/nevery nth value inside a range:9-17/2is 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
| Scheduler | Fields | Time zone | Differences from Unix cron |
|---|---|---|---|
| Unix cron (crontab) | 5 | System local time; some versions accept CRON_TZ= | Also has @hourly, @daily, @weekly, @monthly, @yearly and @reboot |
| Kubernetes CronJob | 5 | The controller's zone, usually UTC; set spec.timeZone to change it | Same syntax, including the @ shortcuts except @reboot |
| GitHub Actions | 5 | UTC only | Shortest interval is 5 minutes; runs can start late, or be dropped, when the service is busy |
| Quartz | 6 or 7: seconds first, optional year last | The JVM's, or one set on the trigger | Weekdays are 1-7 from Sunday; one day field must be ?; adds L, W and # |
| AWS EventBridge | 6: year last, wrapped in cron( ) | UTC for rules; EventBridge Scheduler takes a time zone | Weekdays 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, orconcurrencyPolicy: Forbidin Kubernetes. - Environment. Cron runs with a minimal
PATHand 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 indate +\%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.