Cron expression for the last Friday of the month
At 09:00, on the last Friday of the month.
Next 10 runs
In Quartz, worked out in your browser from the current time.
At a glance
- Runs
- 12 in 2027
- Gap between runs
- 28 days to 35 days
- Expressible in
- EventBridge and Quartz; workarounds for the rest
- Clock changes
- No effect in the zones checked
In each dialect
Every expression here is generated by the tester’s own engine and checked run for run against the others, so “Exact” means the same clock times in the same zone. Each one links to the tester.
Standard cron has no syntax for “the last Friday of the month”, which falls on a different date each month.
Workaround
Schedule 0 9 * * 5 (at 09:00, on Fridays) and let a shell test go ahead only when the same weekday next week falls in another month. In a crontab, % must be written \%, or cron cuts the line there.
0 9 * * 5 [ "$(date -d '+7 days' +\%m)" != "$(date +\%m)" ] && /path/to/commandaws events put-rule --name last-friday-of-month --schedule-expression "cron(0 9 ? * 6L *)"- Wrap it in
cron(…). Day of week is set (6L), so day of month has to be?. The final*is the required year field. - Scheduled rules always run in UTC. For local times, create it in EventBridge Scheduler with
--schedule-expression-timezone.
CronScheduleBuilder.cronSchedule("0 0 9 ? * 6L")- The leading
0is the seconds field, so it fires at the top of the minute. Day of week is set (6L), so day of month has to be?. The optional year is left off. - Uses the JVM’s default zone unless the trigger sets one with
inTimeZone.
Kubernetes CronJob has no syntax for “the last Friday of the month”, which falls on a different date each month.
Workaround
Schedule 0 9 * * 5 and put the test in front of the container’s command, so the Job exits straight away unless the same weekday next week falls in another month. The test uses GNU date, so Alpine and other BusyBox images need coreutils. The container’s clock is UTC unless you set TZ; match it to timeZone.
schedule: "0 9 * * 5"
# in the container:
command: ["sh", "-c", "[ \"$(date -d '+7 days' +%m)\" != \"$(date +%m)\" ] && exec /app/job"]GitHub Actions has no syntax for “the last Friday of the month”, which falls on a different date each month.
Workaround
Schedule 0 9 * * 5 and make the test the first line of the step that does the work, so the step ends early unless the same weekday next week falls in another month. The runner’s clock is UTC; if you set timezone, give the step the same zone with env: TZ.
- cron: '0 9 * * 5'
# in the job:
- run: |
[ "$(date -d '+7 days' +%m)" != "$(date +%m)" ] || exit 0
./your-scriptAzure Functions has no syntax for “the last Friday of the month”, which falls on a different date each month.
Workaround
Schedule 0 0 9 * * Fri and return early unless the same weekday next week falls in another month. UtcNow matches the default UTC schedule; if you set WEBSITE_TIME_ZONE, compare local time instead.
[TimerTrigger("0 0 9 * * Fri")]
// first line of the function:
if (DateTime.UtcNow.AddDays(7).Month == DateTime.UtcNow.Month) return;About this schedule
Quartz and EventBridge write it 6L: the last day 6, which is Friday when Sunday is 1. Unlike the nth weekday, there is no fixed date range for it, since it falls anywhere from the 22nd to the 31st depending on the month’s length, so even Azure needs a date check.
Clock changes
None of these times falls in the hour that clocks skip or repeat in New York, London, Berlin, Helsinki or Sydney, so every dialect runs it normally all year there. Zones that change clocks at other hours can still differ.
Questions
- What is the cron expression for the last Friday of the month?
- It is
0 9 ? * 6L *in EventBridge and0 0 9 ? * 6Lin Quartz. Standard cron, Kubernetes, GitHub Actions and Azure cannot express it in one line, so this page gives a tested workaround for each. - Can a Kubernetes CronJob run on the last Friday of the month?
- Not with the schedule alone. Schedule
0 9 * * 5and put the test in front of the container’s command, so the Job exits straight away unless the same weekday next week falls in another month. The test uses GNUdate, so Alpine and other BusyBox images needcoreutils. The container’s clock is UTC unless you setTZ; match it totimeZone.