Home > Net >  Run different background jobs at optimal times
Run different background jobs at optimal times

Time:01-06

In one of my Azure App Services I have a bunch of web jobs that should run all several hours.

Job 1 - Should run each 1-2 hours
Job 2 - Should run each 2-4 hours
Job 3 - Should run each 4-6 hours

All jobs take 20-30 minutes to complete.

It does not really matter if Job1 runs each hour or all two hours. Both is fine...

As a first approach I created a schedule that looks like this:

Job 1: 0 0 */2 * * *
Job 2: 0 0 */4 * * *
Job 3: 0 0 */6 * * *

This works, but now my App service plan gets pretty exhausted all 6 hours, because then all web jobs will start all at once.
All 4 hours the first two jobs start at once, what is also not optimal.

I would like to find three schedules that will fire my jobs in the right rhythm, but with a quarter of hour (or thirty minutes) shifted to each other.

Is there an easy way how to do so?

I am still struggling to understand the format for the schedules, so maybe you have an idea?

CodePudding user response:

Not optimal, but what comes to my mind is just specify time you want to run

0 0 1,3,5,7,9,11,13,15 * * *

then other job

0 0 2,6,10,14 * * *

and so on.

  •  Tags:  
  • Related