How can I schedule tasks to occur X amount of time after a previous task?

I want to schedule a task to execute on a schedule that doesn’t have a deterministic recurrence. Specifically I want to fire a task X days after the previous occurrence. For example, the schedule would be:

  1. Day 0
  2. 2 days later
  3. 3 days from #2
  4. 2 days from #3
  5. 3 days from #4

…and so on…recurring every 2 and 3 days respectively.

How would I implement this?

You can schedule the next job at the end of the current job. You can pass a parameter to know if the current job is 2 days or 3 days.

You could also have a recurring job every day and determine what is applicable for that day.