Cron on the Last Day of Every Month
Schedule a cron job on the last day of each month using 0 23 28-31 * *. Field breakdown explaining the conditional last-day workaround approach.
Cron Expression
0 23 28-31 * *
Field Breakdown
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | At 0 |
| Hour | 23 | At 23 |
| Day of Month | 28-31 | From 28 to 31 |
| Month | * | Every month (1–12) |
| Day of Week | * | Every day of the week (Sun–Sat) |
Detailed Explanation
The cron expression 0 23 28-31 * * schedules a task to run at 11:00 PM on days 28 through 31 of every month. Combined with a shell check, this effectively targets the last day of each month.
Field-by-field breakdown:
0(Minute): At minute 0. The task fires at the top of the hour.23(Hour): At hour 23 (11 PM). The task runs late in the evening, near the end of the day.28-31(Day of Month): Days 28 through 31. This range captures all possible last days of the month (28 for February, 30 for April/June/September/November, 31 for the rest).*(Month): Every month from January through December. No restriction on which month.*(Day of Week): Every day of the week from Sunday through Saturday. No restriction on the day.
Important: Standard cron does not have a native "last day of month" field. This expression will fire on days 28-31, so you should wrap your command with a shell check like [ "$(date +\%d -d tomorrow)" = "01" ] && your_command to ensure it only runs on the actual last day. Without this guard, it will run multiple times at the end of months with 29, 30, or 31 days. The 11 PM timing ensures all of the day's data is available for processing. This expression is supported by standard cron on Linux/macOS, as well as cloud services like AWS CloudWatch, Google Cloud Scheduler, and GitHub Actions.
Use Case
Perfect for generating end-of-month billing invoices and financial statements that need to capture the complete month's transactions.
Try It — Interactive Builder
at min 0, at hour 23, on day 28-31
Next 10 Executions
Ctrl+Shift+C to copy expression