How can I create a cron job that will run on the last day of every month?
Standard cron has no 'last day' value. Use 0 0 L * * where L is supported, or 0 0 28-31 * * plus a check that tomorrow is the 1st. Leap years break month lists.
How can I create a cron job that will run on the last day of every month?
There is no exact, portable five-field Unix cron expression for “the last day of every month.” Traditional Unix/Vixie cron, robfig/cron, Jenkins built-in cron, and NCrontab do not accept L. 0 0 L * * works with dragonmantank/cron-expression; Quartz and AWS EventBridge support L using their six-field forms. For Unix crontab, use 0 0 28-31 * * with the runtime guard below, so the command continues only when tomorrow is the first day of a month.
# dragonmantank/cron-expression only; Quartz and AWS need their six-field form
0 0 L * *# portable trigger for a runtime "tomorrow is day 1" guard
0 0 28-31 * *# the guarded crontab line (GNU date)
# on macOS/BSD use: date -v+1d +\%d
0 0 28-31 * * [ "$(date -d tomorrow +\%d)" = "01" ] && commandRead the guarded trigger field by field: minute 0, hour 0, days 28 through 31, every month, and every day of the week. Your runtime check narrows those four candidate nights to the one true month-end date. The month-enumeration approach you may have seen (0 0 30 4,6,9,11 * for 30-day months and 0 0 31 1,3,5,7,8,10,12 * for 31-day months) is correct for those months, but February breaks it: 28 runs a day early in leap years and 28,29 fires twice in them.
0 0 L * * on Crontap
Month length changes, and February changes again in leap years. Treating February 28 as month-end runs a day early in leap years; listing both 28 and 29 runs twice in those years. Either mistake can close accounting periods, create reports, or rotate data on the wrong date. The candidate-days-plus-runtime-check pattern avoids that month-boundary error on any cron, while L avoids it only when your dialect implements the modifier. The dedicated guides cover Quartz, AWS EventBridge, robfig/cron, Jenkins, NCRONTAB and PHP cron-expression.
Read the dedicated guide: Cron expression for the last day of the month.
0 0 L * * — command
View future cron matches in a calendar
September 2026 · UTC
0 runs
0 0 28-31 * * — command
See this cron expression on the calendar view example
Write the cron here. Run it on Crontap.
WordPress, Shopify, Railway, Cloud Run, Vercel, HubSpot, Ghost, your own box. If it answers HTTP, Crontap can drive it on a clock you can read, in the timezone that actually matters, and page you when something breaks.
1.9k+ teams · Free forever tier · No credit card
Permalink: https://tool.crontap.com/help/cron-job-expression-every-last-day-of-the-month