I want to schedule a trigger to run every 21 days starting march 1 , so that march 1 is sunday , 21 days later is sunday again

But the trigger should run evrry 21 days

March 1 - first run (manual run)
21 days later - March 22 ( trigger run)
April 12

@Ragavi_Rajasekar

Use this CRON expression. Just enable the trigger after 1st march your manual run so there won’t be double run on that day.

0 0 0 1/21 * ? *

But this expression runs on 1st sunday and 4 the sunday … this way it will not have 21 days gap after 4 th sunday , it will execute on april 1st sunday

@Ragavi_Rajasekar

There is no cron expression that you can write to run for every 21 days..instead one better way is have queue triggers enabled and run the first job and at the end of first job add a queue item to the queue with deffered/postponed date of 21 days..and as queue triggers is enabled after 21 days it would trigger and the cycle continues till you stop

Cheers

1 Like

Hi @Ragavi_Rajasekar

As Ashok and Anil also shared, direct cron expression is not possible for this scenario as cron exp works on fixed time fields and not on a running date count since the last execution.

However, you can try below approach:

  1. have the logic implemented in your code to save the last execution date time in a file.

  2. apply the cron to run every day

  3. check first thing in the code “time elapsed” since last execution. If 21 days have passed, run the process else stop the process.

You can consider to add this logic in your main process only or you can also consider to create a separate process with this logic which runs everyday and if 21 days since last execution(per details saved in file) have passed then start running your main process else do nothing.

Hope this helps.

Regards

Sonali

How about creating a daily trigger to run every 21 days ?