Cron expression for twice a month
0 0 1,15 * *
At 00:00, on day 1 and 15 of the month. It runs on 24 days a year.
Runs on the 1st and 15th of every month at midnight. This is not exactly every two weeks. The gap from the 1st to the 15th is always 14 days, but from the 15th to the next 1st it is 14 to 17 days, depending on the month’s length.
Field by field
| Field | Value | Matches |
|---|---|---|
| minute | 0 |
0 |
| hour | 0 |
0 |
| day of month | 1,15 |
1, 15 |
| month | * |
every value |
| day of week | * |
every value |
Examples
crontab
Run crontab -e and add:
0 0 1,15 * * /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 1,15 * *"
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 1,15 * *' # 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 month
[Timer]
OnCalendar=*-*-01,15 00: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 "*-*-01,15 00:00:00". Persistent=true runs a missed job after
downtime, which cron can’t do.
AWS EventBridge
cron(0 0 1,15 * ? *)
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: monthly and yearly
-
Every month:
0 0 1 * * -
On the 15th of every month:
0 0 15 * * -
On the last day of the month:
55 23 28-31 * * -
On the first Monday of the month:
0 9 1-7 * * -
Every quarter:
0 0 1 */3 * -
Every 6 months:
0 0 1 */6 * -
Every year:
0 0 1 1 *
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 month?
Use 0 0 1,15 * *. It means “At 00:00, on day 1 and 15 of the month”. It runs on 24 days a year.