0

Is there a way to schedule an apex class(schedulable of course) to run every second week?

I thought I could do it in the UI by scheduling 2 jobs for 2nd and 4rd Friday of the month, but the moment I try to schedule the second one I get the error:

Error: This Apex class is already scheduled for execution.

I have seen this answer, but that doesn't really fit my needs. My batch should only start executing every second Friday after work hours.

I was also thinking about using cron, but couldn't find a way to schedule it for every second and fourth Friday of the month.

1
  • what about this cron: 0 1 8-14,21-28 * 5
    – kurunve
    Commented Nov 7, 2017 at 7:06

1 Answer 1

2

Here are the cron expressions for the schedule.

Every 2nd Friday of a Month at 8 PM

0 0 20 ? 1/1 FRI#2 *

Every 4th Friday of a Month at 8 PM

0 0 20 ? 1/1 FRI#4 *

The code to run in developer console anonymous block to schedule the jobs

System.schedule('2nd Friday Schedule', '0 0 20 ? 1/1 FRI#2 *', new YourApexClass());
System.schedule('4th Friday Schedule', '0 0 20 ? 1/1 FRI#4 *', new YourApexClass());

You must log in to answer this question.

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