Get last Day in a month


is there any possibility to get an “event” if the actual day is the last day of the month ? First day is no problem but the last day ?


Google is your friend :slight_smile:

0 23 28-31 * * [ "$(/bin/date +\%d -d tomorrow)" = "01" ] && /your/

Untested, but according to the Quartz Scheduler documentation you should be able to set “L” for last day in a cron expression:

The ‘L’ character is allowed for the day-of-month and day-of-week fields. This character is short-hand for “last”, but it has different meaning in each of the two fields. For example, the value “L” in the day-of-month field means “the last day of the month” - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means “7” or “SAT”. But if used in the day-of-week field after another value, it means “the last xxx day of the month” - for example “6L” or “FRIL” both mean “the last friday of the month”. You can also specify an offset from the last day of the month, such as “L-3” which would mean the third-to-last day of the calendar month. When using the ‘L’ option, it is important not to specify lists, or ranges of values, as you’ll get confusing/unexpected results.

You could test this rule:

rule "Last Day of Month"
	Time cron "0 0 0 L * ?"
	// do something

Not always. But thank you for the example

Yeah that would be awesome. Thanks. I will try it.


1 Like

Please report back the results :wink:

… and select a post as the solution to close it properly :smiley:

1 Like