Cron: Last Day of the Month
There is no clean last-day-of-month in classic cron. Here are the two working approaches and when to use each.
The catch
Classic Unix cron has no symbol for “last day of the month”, because months vary from 28 to 31 days. You cannot write it in one field.
Recipe 1: guard a range
Run daily near month-end and let the command check whether tomorrow is the 1st: 0 0 28-31 * * [ "$(date -d tomorrow +%d)" = 01 ] && yourjob. The cron only tries on the 28th–31st; the shell test fires the job exactly once, on the true last day.
Recipe 2: Quartz L syntax
Schedulers built on Quartz (Java, Spring) support L in the day-of-month field: 0 0 0 L * ? means midnight on the last day. This does not work in Unix crontab.
Common variations
Last weekday of the month in Quartz: 0 0 0 LW * ?. Last Friday: 0 0 0 ? * 6L.
FAQ
Why can't cron just say 'last day'?
Standard cron matches fixed numbers; month length varies (28–31), so there is no single day number that always means the end.
What does L mean in a cron expression?
In Quartz-based schedulers, L in the day-of-month field means the last day of the month. Unix crontab does not support it.
How do I run reliably on the last day in plain cron?
Schedule 0 0 28-31 * * and add a shell test that only runs the job when tomorrow is the 1st.