Cron expression for twice a day
0 0,12 * * *
At 00:00 and 12:00. It runs twice a day, 730 times a year.
Runs at midnight and noon. Any two hours work in the list: 0 9,21 * * * runs at 9 AM and 9 PM. If you need a different minute at each time, like 08:30 and 17:00, write two crontab lines. Minute and hour lists combine, so 0,30 8,17 * * * would run four times.
Field by field
| Field | Value | Matches |
|---|---|---|
| minute | 0 |
0 |
| hour | 0,12 |
0, 12 |
| day of month | * |
every value |
| month | * |
every value |
| day of week | * |
every value |
Examples
crontab
Run crontab -e and add:
0 0,12 * * * /usr/local/bin/job.sh >> /var/log/job.log 2>&1
Kubernetes CronJob
apiVersion: batch/v1
kind: CronJob
metadata:
name: my-job
spec:
schedule: "0 0,12 * * *"
timeZone: "Etc/UTC" # Kubernetes 1.27+
concurrencyPolicy: Forbid # skip a run if the last one is still going
jobTemplate:
spec:
template:
spec:
containers:
- name: job
image: ghcr.io/acme/job:1.0
restartPolicy: OnFailure
GitHub Actions
on:
schedule:
- cron: '0 0,12 * * *' # UTC
GitHub evaluates schedules in UTC, and runs can start several minutes late at busy times.
systemd timer
# /etc/systemd/system/job.timer
[Unit]
Description=Run job.service twice a day
[Timer]
OnCalendar=*-*-* 00,12:00:00
Persistent=true
[Install]
WantedBy=timers.target
Enable it with systemctl enable --now job.timer, and check the next runs with
systemd-analyze calendar "*-*-* 00,12:00:00". Persistent=true runs a missed job after
downtime, which cron can’t do.
AWS EventBridge
cron(0 0,12 * * ? *)
EventBridge cron has six fields (the last is the year), uses ? in either the day-of-month or the
day-of-week field, and numbers weekdays from 1 (Sunday) to 7. Rules run in UTC; EventBridge Scheduler also
accepts a time zone.
Similar schedules: daily
-
Every day at midnight:
0 0 * * * -
Every day at 1 AM:
0 1 * * * -
Every day at 2 AM:
0 2 * * * -
Every day at 3 AM:
0 3 * * * -
Every day at 6 AM:
0 6 * * * -
Every day at 8 AM:
0 8 * * * -
Every day at 9 AM:
0 9 * * * -
Every day at noon:
0 12 * * * -
Every day at 5 PM:
0 17 * * * -
Every day at 11:59 PM:
59 23 * * * -
Every other day:
0 0 */2 * *
Have a different schedule? Paste any expression into the Cron Expression Generator, or browse all cron examples.
Sources
- POSIX: crontab
- crontab(5) manual page
- Kubernetes docs: CronJob
- GitHub Actions docs: schedule event
- systemd.time(7): calendar events
- AWS docs: EventBridge Scheduler cron expressions
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
How do I run a cron job twice a day?
Use 0 0,12 * * *. It means “At 00:00 and 12:00”. It runs twice a day, 730 times a year.