Cron expression

Cron last day of the month

One cron expression cannot say "last day of the month", but a short crontab workaround can. Below: the lines, how they work, what daylight saving does to them, and how to get an alert when the job stops.

toolsCrontab workaround
0Minute
0Hour
28-31Day of month
*Month
*Day of week

At 00:00, on days 28 through 31 of the month.

crontab -e
0 0 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /usr/local/bin/job.sh

How do you run a job last day of the month with cron?

The line runs on every day that could be the last one, the 28th to the 31st, and the test lets the job through only when tomorrow is the 1st. In a crontab, % must be written as \%.

crontab -e
0 0 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /usr/local/bin/job.sh

What does 0 0 28-31 * * mean?

At 00:00, on days 28 through 31 of the month.

FieldWrittenMeans
Minute00
Hour00
Day of month28-3128 through 31
Month*every month
Day of week*every day of week

How often does it run?

On a day it runs, it runs once. It runs on 41 days of 2027, 41 runs in all. The gap between runs is not constant: it varies from 1 day to 28 days.

Runs on a day it runs
1
Days it runs in 2027
41
Runs in 2027
41
Shortest gap
1 day

When is this schedule useful?

End-of-month closing: final invoices, month-end snapshots and reports that must include every day of the month.

What should you watch out for?

The test uses GNU date. On macOS and BSD, write date -v+1d +%d instead of date -d tomorrow +%d.

What happens when the clocks change?

On Sunday 14 March 2027, clocks in America/New_York jump from 02:00 to 03:00. This schedule does not run that day, so the change does not touch it.

On Sunday 1 November 2026, clocks in America/New_York fall back from 02:00 to 01:00, so the hour from 01:00 happens twice. This schedule does not run that day, so the change does not touch it.

A server that keeps its clock on UTC never sees either change. The next run calculator previews any zone.

How do you get an alert when it stops running?

Create a OnCalendar check with the schedule *-*~01 00:00 and 5 minutes of grace, then ping it at the end of the job. If a run does not report in by the end of the grace time, CronMissed sends an alert.

crontab -e
0 0 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /usr/local/bin/job.sh && curl -fsS --max-time 10 --retry 5 --retry-connrefused -o /dev/null "https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10"

The snippet builder writes the same ping for systemd, GitHub Actions, Vercel, Kubernetes and backup scripts.

Questions and answers

What does 0 0 28-31 * * mean in cron?
At 00:00, on days 28 through 31 of the month. On its own it does not give this schedule; the crontab lines on this page add what one expression cannot.
How often does 0 0 28-31 * * run?
On a day it runs, it runs once. It runs on 41 days of 2027, 41 runs in all. The gap between runs is not constant: it varies from 1 day to 28 days.
How do I get an alert when this job stops running?
Create a OnCalendar check with the schedule *-*~01 00:00 and 5 minutes of grace, then add the ping to the end of the job so it requests the check URL after each successful run. If a run does not report in by the end of the grace time, CronMissed alerts you by email, Slack, Discord, Telegram, ntfy or webhook.

Know the first time this schedule misses a run

CronMissed expects a ping at every run of 0 0 28-31 * *. When one is late or reports a failure, you get an alert by email, Slack, Discord, Telegram, ntfy or webhook.