Expand my Community achievements bar.

Run Scheduler 3 times irrespective of the Cron Expression

Avatar

Level 1

Example:

My Cron Expression : 0 50,25,0 22 ? * * - This will execute everyday at 10.0pm, 10.25pm and 10.50pm

why 3 times : 1st try is actual and 2 more are retries for fail safe (Exception scenarios)

Consider a scenario in which all 3 time the scheduler failed and it triggered email to admin and admin make changed to configuration (cron expression) to re-run the scheduler. Now the admin dont want to run scheduler for 3 times so he changed the expression to [0 0 23 ? * *] which is 11pm.

So normally the scheduler will run only one time at 11pm.

My Requirement:

Even though the admin schedule to run the scheduler once or twice or 5 times etc, irrespective of the cron expression, the scheduler must run 3 times. How to do this?

 

3 Replies

Avatar

Employee Advisor

The first question I have is, why admin is changing the cron expression, it should be derived by runmodes.

 

Scheduler will always respect the cron expression, so if you want to avoid cron expression, We should avoid AEM scheduler and use other options outside AEM, say create a servlet in AEM, and implement AWS EventBridge Scheduler + Lambda function, EventBridge Scheduler will invoke multiple times (3 times in your case), invoking Lambda function, which will call AEM servlet to perform the task in AEM.

https://aws.amazon.com/blogs/compute/introducing-amazon-eventbridge-scheduler/

Avatar

Level 1

Hi @Mohit_KBansal,

Thanks for the response.

On the 3rd attempt we will be triggering email saying that the scheduler failed. If the admin don't want to wait till next day for the scheduler to run, he can go and change the configuration to run it again that is the flexibility.

Yes agreed Scheduler always depends on the cron expression.
But Don't want to use any third party implementation just want to know is there is way. Thanks.

Avatar

Employee Advisor

In that case, you may need to write a custom scheduler kind of logic in AEM.