0

I need to schedule my class to run every two weeks on Friday.

I see this in questions.

However It is not excactly what I want.

And I can not came up with an idea hot to write a cron expression for this : based on :

Maybe someone has already done something similar ?

Any help will be appreciated.

thank you

2
  • When you say this is not exactly what you want, are you looking to only ever schedule a single instance of the class or what is your desired solution?
    – TSmith
    Dec 8, 2021 at 14:06
  • @TSmith I need to schedule EVERY TWO WEEKS . NOT on the 2nd Friday and on 4th Friday of month. Dec 8, 2021 at 14:31

2 Answers 2

3

I can only offer a solution by scheduling two instances of your class, one on the 2nd Friday of Month, the other on 4th Friday of month.

  • 2nd Friday : 0 0 0 ? 1/1 FRI#2 *
  • 4th Friday : 0 0 0 ? 1/1 FRI#4 *

As you can see, FRI#N can be changed if you wish to go with 1st and 3rd Friday also.

I would note that the impact of a month with 5 Fridays should be tested on your side.

2
  • 2
    It's worth noting that 0 0 0 * * FRI#2,FRI#4 * would work, except that System.StringException: Support for specifying multiple "nth" days is not implemented. Two jobs is the way to go here, unfortunately.
    – sfdcfox
    Dec 8, 2021 at 14:15
  • @sfdcfox Ok, thanks Dec 9, 2021 at 9:00
0

You need to schedule two jobs.

One with 0 0 8 ? 1/1 FRI#2 *

and second with 0 0 8 ? 1/1 FRI#4 *

Change the 8 as per your time as it denotes the time at which the job will run.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .