Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz: setting cron expression to run on the 1st and Last day of month

Quartz documentation gives an example for running a cron job on the last day of every month, like this:

0 15 10 L * ?   

Fire at 10:15am on the last day of every month

However, I'd like to run a cron job on the 1st AND Last day of the month. I would expect the cron would look somthing like this:

0 15 10 1,L * ?

But this syntax is not valid by quartz.

I couldn't find any proper/similar example in their tutorial. Any suggestions?

like image 478
Elad Tabak Avatar asked Dec 22 '25 03:12

Elad Tabak


1 Answers

So after some digging in quartz code I found this:

// throw an exception if L is used with other days of the month
if(exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
    throw new ParseException("Support for specifying 'L' and 'LW' with other days of the month is not implemented", -1);
}

org.quartz.CronExpression (quartz 2.2.2).

It seems 'L' is not supported for day-of-month with other days of the month. Too bad it's not anywhere in their documentation :(

like image 86
Elad Tabak Avatar answered Dec 23 '25 18:12

Elad Tabak