Cron / on the last day of every month
Cron on the last day of the month: the 28–31 trick
Standard cron has no "last day" value. The usual trick: run on days 28–31 and let the job check whether tomorrow is the 1st.
The closest expression
0 23 28-31 * *
In words: At 23:00 on every day-of-month from 28 through 31.
Field by field
| Field | Value | Means |
|---|---|---|
| Minute (0–59) | 0 | minute 0 |
| Hour (0–23) | 23 | hour 23 |
| Day of month (1–31) | 28-31 | every day-of-month from 28 through 31 |
| Month (1–12) | * | every month |
| Day of week (0–6, Sunday = 0) | * | every day of the week |
Next runs
Starting from 2026-11-27 00:00 UTC:
- Sat, Nov 28, 2026, 23:00 UTC
- Sun, Nov 29, 2026, 23:00 UTC
- Mon, Nov 30, 2026, 23:00 UTC
- Mon, Dec 28, 2026, 23:00 UTC
- Tue, Dec 29, 2026, 23:00 UTC
Try other expressions and timezones in the cron expression tool.
The check
0 23 28-31 * * [ "$(date -d tomorrow +\%d)" = "01" ] && /path/to/job.sh
This uses GNU date; in crontab, % must be escaped as \%. In application code, check new Date(Date.now() + 86400000).getUTCDate() === 1. Quartz-style schedulers and AWS EventBridge support L in day-of-month: cron(0 23 L * ? *).
The same schedule on other platforms
Linux crontab. Edit with crontab -e. Runs in the server’s timezone unless you set CRON_TZ (cronie) or TZ.
0 23 28-31 * * /path/to/job.sh >> /var/log/job.log 2>&1
GitHub Actions. Schedules run in UTC on the default branch, and runs can start late when GitHub is busy.
on:
schedule:
- cron: '0 23 28-31 * *'
Kubernetes CronJob. Set timeZone (Kubernetes 1.27+) or the schedule follows the controller’s timezone, usually UTC. concurrencyPolicy: Forbid stops runs from overlapping.
apiVersion: batch/v1
kind: CronJob
metadata:
name: my-job
spec:
schedule: "0 23 28-31 * *"
timeZone: "Etc/UTC"
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox
command: ["sh", "-c", "echo running"]
AWS EventBridge Scheduler. Six fields (the last is the year); one of day-of-month or day-of-week must be ?. Pick the timezone on the schedule.
cron(0 23 28-31 * ? *)
Wisp. Describe the job and say how often in plain words — Wisp writes the function, turns the schedule into this cron expression in your timezone, and runs it with logs and error alerts.
"On the last day of every month, fetch new orders from Shopify and post a summary to Slack."
Questions
Why not just run on the 1st? Often that is simpler: a job at 00:05 on the 1st can process the previous month. Use the last-day trick only when it must run before the month ends.
Try any expression in the cron tool · Run it on a schedule with Wisp