Cron expression for twice a day
The cron expression 0 6,18 * * * runs a job twice daily — at 6 AM and 6 PM. The comma in the second field lists two distinct hours; any field accepts a comma-separated list of values. Useful for jobs that should run in the morning and evening but not all day. AWS EventBridge uses cron(0 6,18 * * ? *).
Quick reference
| Platform | Expression |
|---|---|
| Unix / Linux crontab | 0 6,18 * * * |
| Kubernetes CronJob | 0 6,18 * * * |
| GitHub Actions | 0 6,18 * * * |
| AWS EventBridge | cron(0 6,18 * * ? *) |
| Quartz (Java) | 0 0 6,18 ? * * |
How does the comma syntax work?
A cron field accepts three structural forms: a single value (5), a range (1-5), or a list (1,3,5). The comma form lists discrete values — useful when the schedule isn’t a simple step.
You can combine all three in one field. 0,30 9-17 * * 1-5 reads as “minute 0 OR minute 30, between hour 9 and hour 17, every day-of-month, every month, day-of-week 1 through 5” — every 30 minutes during business hours on weekdays. Each field is independent.
The comma list has no implicit ordering and no de-duplication. 0 6,6,18 * * * is equivalent to 0 6,18 * * * — duplicates are ignored. The parser also doesn’t validate logical sense — 0 25,30 * * * (with hour 25) is a parse error, not a silent skip.
Variations
| Schedule | Expression |
|---|---|
| Twice daily — 6 AM and 6 PM | 0 6,18 * * * |
| Twice daily — 9 AM and 5 PM | 0 9,17 * * * |
| Three times daily — morning, noon, evening | 0 8,12,18 * * * |
| Twice daily on weekdays only | 0 6,18 * * 1-5 |
| Twice daily at quarter past — 6:15 and 18:15 | 15 6,18 * * * |
| Four times daily, irregular | 0 6,8,17,22 * * * |
| Twice daily in AWS | cron(0 6,18 * * ? *) |
How do I use it on each platform?
Linux crontab:
0 6,18 * * * /usr/local/bin/sync-feeds
Kubernetes CronJob:
apiVersion: batch/v1
kind: CronJob
metadata:
name: sync-feeds
spec:
schedule: "0 6,18 * * *"
timeZone: "America/Los_Angeles"
jobTemplate:
spec:
template:
spec:
containers:
- name: sync
image: my-org/sync-feeds:1.0
restartPolicy: OnFailure
AWS EventBridge Scheduler:
Type: AWS::Scheduler::Schedule
Properties:
Name: sync-feeds
ScheduleExpression: 'cron(0 6,18 * * ? *)'
ScheduleExpressionTimezone: 'America/Los_Angeles'
FlexibleTimeWindow:
Mode: 'OFF'
Target:
Arn: !GetAtt SyncFunction.Arn
RoleArn: !GetAtt SchedulerRole.Arn
GitHub Actions:
on:
schedule:
- cron: '0 6,18 * * *'
GitHub Actions allows multiple cron entries under schedule — equivalent to a comma list, but more readable when the times are unrelated:
on:
schedule:
- cron: '0 6 * * *' # morning sync
- cron: '0 18 * * *' # evening sync
Common mistakes
Whitespace inside the comma list. 0 6, 18 * * * (note the space after the comma) is rejected by most cron parsers because they tokenize on whitespace. Comma lists must be contiguous: 0 6,18 * * *.
Confusing 6,18 with 6-18. 6,18 is exactly two values (6 and 18). 6-18 is a range — every hour from 6 through 18 inclusive (13 values). Easy to mistype when you mean “twice a day at the boundaries”.
Using 0 6,18 * * * and expecting “exactly 12 hours apart”. It fires at 6:00 and 18:00 — 12 hours apart. But 0 9,17 * * * (9 AM and 5 PM) is 8 hours apart in the morning gap and 16 hours in the evening gap. Cron lists discrete clock times; it doesn’t compute spacing for you.
For other schedules see common cron schedules, or build a custom expression with the Cron Expression Builder.
Frequently asked questions
- How do I list multiple values in a cron field?
- Use a comma. `0 6,12,18 * * *` runs at 6 AM, noon and 6 PM. The comma list works in any field — `0 0 1,15 * *` runs on the 1st and 15th of every month, `0 9 * * 1,3,5` runs Monday/Wednesday/Friday at 9 AM. Mix and match: `0,30 9-17 * * 1-5` runs every 30 minutes during business hours on weekdays.
- What is the difference between `0 6,18 * * *` and `0 */12 * * *`?
- They produce the same firing times if both align — `*/12` from 0 fires at 00:00 and 12:00, while `6,18` fires at 06:00 and 18:00. Different starting points; same cadence. For arbitrary "twice daily" times like 6 AM and 6 PM, use the comma list. For evenly-spaced "every N hours starting from midnight" use the step.
- Can I list times that aren''t evenly spaced?
- Yes — comma lists support any combination. `0 9,17 * * *` runs at 9 AM and 5 PM (8 hours apart, then 16 hours apart). `0 6,8,17,22 * * *` runs four times daily at irregular intervals. The cron parser doesn't care about spacing.
Need a different schedule?
Build cron expressions for Unix, Kubernetes and AWS — with a human-readable description and the next 5 run times.
Open the Cron Expression Builder →Related
Cron expression for every 5 minutes
The cron expression `*/5 * * * *` runs every 5 minutes in Linux crontab, Kubernetes, GitHub Actions; `cron(*/5 * * * ? *)` in AWS EventBridge.
Cron expression for every 15 minutes
The cron expression `*/15 * * * *` runs every 15 minutes — at :00, :15, :30, :45 — across Linux, Kubernetes, GitHub Actions and AWS.
Cron expression for every hour
The cron expression `0 * * * *` runs once per hour on the hour. Same syntax in Linux, Kubernetes and GitHub Actions; `cron(0 * * * ? *)` in AWS EventBridge.
Cron expression for daily at midnight
The cron expression `0 0 * * *` runs once daily at midnight. Watch the timezone — Kubernetes < 1.25 and AWS EventBridge default to UTC, not local time.
Cron expression for every weekday
The cron expression `0 9 * * 1-5` runs at 9 AM Monday through Friday. AWS uses `cron(0 9 ? * MON-FRI *)` because day-of-week numbering differs.
Cron expression for the first of every month
The cron expression `0 0 1 * *` runs at midnight on the 1st of every month. AWS uses `cron(0 0 1 * ? *)`.