Cron expression to execute the last day of the month

Cron expression to execute the last day of the month

Hi all,

I would like some help on what a cron expression should look like to run the workflow every last day of the month.

  • n8n version: 0.166.0
  • Running n8n via [Docker, npm,, desktop app]: npm

The easiest solution would be to create a cron job which runs on the first day of the month at 00:00.
This would look like: 0 0 1 * *

The problem with the last day of a month is, that the last day of a month changes, it could be 28,30 and 31
so you would need 3 different cron jobs for each of 28,30 and 31.
59 23 30 4,6,9,11 *
59 23 30 1,3,5,7,8,10,12 *
59 23 28 2 *

And then you have the issue with leap years, the “28” cron job for February would run one day early.
Afaik there is no way of using leap years with cron.

Maybe someone more knowledgable with cron knows a trick to do this on the last day of every month.

EDIT: added some sample cron expressions with links to, amazing site to learn and try cron expressions!

1 Like

Thanks for the answer.

I did some searching and found this cron expression: 0 0 L * *

Do you know if it works on n8n?

Hey @gersonofm,

L is not a standard Cron attribute so will not work. One thing you could do is run it daily then check if it is the last day of the month or not. If it is continue with the workflow if not do nothing.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.