Cron Expression Help Required

Hi Everyone, I have to run few process as below

Project Trigger Day
CM-ATC T1 Last week-Tue
CM-SC T1 2nd week-thus
CM-ATC T2 Last week-Wed
CM-SC T2 2nd week-Fri

I have cron Expression as:

0 0 22 ? * 4#5 * :-which means–At 10:00 PM, on the fifth Tuesday of the month

however some month does not have tue on last week and in such cases it would fail , I want to make sure that we should run it on last week on tuesday or friday .

Only week it should consider is a week which has 7 days.

This logic i am not able to crack.

Please help me if anyone has any solution in this scenario.

@sachin.bais,

As per my understanding, CRON don’t validate the logics like If Else.
In your case you will have to create two Triggers and monitor them on monthly basis for which one to enable.

You can also Enable both the triggers but you will have to add a logic to check if the bot already ran for the month or not. If not then Run else skip.

Thanks,
Ashok :slight_smile:

1 Like

@sachin.bais

Is this what you need

Expression: 0 0 22 ? * 3L *

For Future generation of cron :

cheers

2 Likes

Hello Anil, Thanks for your reply.

No. The Last week tuesday does not solve the problem. Lets consider if in last week you don’t have Tuesday then it should work on monday.

This one is tricky since if condition cant be passed on cron expression.

Thanks again for your comment

1 Like

@sachin.bais

Then cron would not be your case…

Cheers