Tools › Cron examples › the last day of the month

Cron expression for the last day of the month

The cron expression for the last day of the month is:

0 0 28-31 * *

What it does

Cron cannot express 'last day' directly. This schedule fires on days 28 to 31, and the command must check whether tomorrow is the 1st.

Field by field

FieldValueMeaning
Minute0exactly 0
Hour0exactly 0
Day of month28-31range 28-31
Month*every value
Day of week*every value

Typical uses

End-of-month billing and closing tasks.

Watch out for

Use: 0 0 28-31 * * [ "$(date -d tomorrow +\%d)" = "01" ] && /path/to/job. The \% escape is required because a bare % means newline in crontab.

Add it to your crontab

crontab -e, then add:

0 0 28-31 * * /path/to/command >> /var/log/myjob.log 2>&1

Related schedules

every minuteevery 5 minutesevery 10 minutesevery 15 minutesevery 30 minutesevery hourevery 2 hoursevery day at midnightevery day at 3amevery weekday at 9amevery 15 minutes during business hoursevery Mondayevery Sunday at midnighton weekendson the first day of every monthevery quartertwice a day
Copied to clipboard