Cron Expression for the Last Day of Every Month
Approximate the last day of each month using 0 0 28-31 * *. Standard cron cannot directly express "last day," so scripts or special syntax may be needed.
Expression
0 0 28-31 * * At 00:00 on days 28-31 of every month (approximate)
Use Cases
- • Running end-of-month financial close procedures
- • Generating monthly summary reports
- • Archiving monthly data before the new month begins
- • Resetting monthly counters just before the new month
Code Examples
Crontab
# At 00:00 on days 28-31 of every month (approximate)
0 0 28-31 * * /path/to/your/script.sh GitHub Actions
name: Scheduled Job
on:
schedule:
- cron: '0 0 28-31 * *'
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Running Last Day of Every Month" systemd Timer
[Unit]
Description=Last Day of Every Month timer
[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true
[Install]
WantedBy=timers.target Tips
- ✓ Standard cron has no "last day" keyword; use a script to check the date
- ✓ A common workaround: [ "$(date +\%d -d tomorrow)" = "01" ] && your_command
- ✓ Some systems like AWS EventBridge support L for last day
- ✓ This expression runs on days 28, 29, 30, and 31 when they exist
Frequently Asked Questions
Can cron run on the last day of the month?
Standard five-field cron cannot express "last day" directly. The common workaround is to run a wrapper script daily that checks if tomorrow is the 1st. Some extended cron implementations (like AWS, Quartz) support the L character for last day.
What happens if I specify day 31 in February?
Cron simply skips the execution when the day does not exist. A cron job set for day 31 will not run in February, April, June, September, or November.