Expression to run job on end of every month : Camel,Quartz

2.1k Views Asked by At

I am trying to run my job every end of month but i am getting an error every time i add cron expression :

from("timer://ratingTimer?cron=0+52+12+++") this is i am trying to run my job for specific time. Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: timer://ratingTimer?cron=0+52+12+%3F++* due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{cron=0 52 12 ? * *}]

1

There are 1 best solutions below

14
On

We will schedule cron on 28,28,29 and 31’st of each month. Now find if today is the last day of the month. To find it check if the next day is 01’st of next day and then only execute any command.

Below command will return the date of the next day.

date +%d -d tomorrow

Now check if tomorrow is 01.

[ "$(date +%d -d tomorrow)" = "01" ] && echo "True"

If the next day is 01 then above command will print “True” on screen. Here you can use the above script in crontab and change echo with your command.

59 23 28-31 * * [ “$(date +%d -d tomorrow)” = “01” ] && /root/script.sh

Check more in below url.

CRON job to run on the last day of the month

AND

quartz scheduler: run on last day of the month

from("cron://ratingTimer?schedule=0+0+3+L+*+?")