Cron Expression for the Last Day of the Month

Last day of the month, 12 times a year
0 23 28-31 * *

Cron reads this as: at 23:00, on day-of-month 28 through 31.

Next 5 runs

These are candidate days, not runs

Cron alone cannot express this schedule, so the expression deliberately matches several days and a shell test picks the right one. The times below are the days cron will wake up; the guard shown further down lets exactly one of them through.

These times are in your browser's local time zone. Cron itself uses the server's zone, which on most cloud hosts is UTC. If the difference matters here, see time zones & DST.

When to use this schedule

Use it for month-end closing, final reconciliation, or a statement that has to cover the complete month. This is one of the few common schedules that standard Unix cron cannot express directly.

What to watch out for

There is no L token in standard cron, and no month has a consistent last day, so 0 23 31 * * silently skips February, April, June, September and November. The portable approach narrows cron to the four candidate days and lets the shell decide which one is the last: schedule 28-31 and guard the command with a test on tomorrow's date. Quartz users can write 0 0 23 L * ? directly instead.

The crontab line

This schedule needs a shell guard, because cron alone cannot express it. The expression narrows cron to the candidate days and the test lets exactly one of them through:

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

Crontab requires the \% escaping. An unescaped % is turned into a newline, and everything after it is fed to the command on standard input. See the crontab guide for the full rule.

Related schedules

Variations on last day of the month
ExpressionSchedule
0 0 23 L * ?The Quartz equivalent
0 23 31 * *The broken version: skips 5 months
0 0 1 * *First of the month instead

Build your own

If this page doesn't cover the schedule you need, compose it field by field in the visual builder, or paste an expression you already have into the explainer for a per-field breakdown. The examples library has sixty schedules in one place, and the guides cover crontab syntax, time zones, troubleshooting and production practices.