Cron for the last day of month

Month-end schedules are tricky because cron support differs by platform. Some engines support L for "last day", while standard 5-field cron often does not.

Common month-end patterns
  • 0 0 L * * → last day at 00:00 (only if your scheduler supports L)
  • 0 0 28-31 * * + guard clause → portable fallback across basic cron engines
  • 0 23 28-31 * * + timezone pinning → safer for end-of-day reporting windows

Portable fallback strategy

  1. Schedule on days 28-31 at your desired time.
  2. Pin scheduler timezone explicitly (UTC or your business timezone).
  3. In code, run only when today is the actual month-end date.
  4. Keep the job idempotent so retries do not duplicate side effects.
Quick check: test February (including leap years), 30-day months, and 31-day months before shipping month-end automations.

If your runtime supports calendar-aware scheduling (instead of plain cron), prefer it for billing and financial cutoffs. Otherwise, the 28-31 + guard approach is the most reliable cross-platform option.