Run different background jobs at optimal times - azure

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?

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.

Related

Cron Expression for running job every 4 hours starting at 4pm . But should not run between 12am to 7am of the day

I am trying to create a Cron Expression for running job every 4 hours starting at 4pm, but should not run between 12am to 7am of the day.
So far I tried to do this but it does not work.
0 0 16/4 ? 0-2,7-23 * * *
This could be your cron expression.
0 0 16/4,20,8,12 ? * * *
Use this link to get exactly what you are seeking for. It will also helps you with the next execution time.

How to run cron daily from one time to another time with frequency of 1 minute

I am trying to run function I need to run daily from 2 am to 5 am each minute,this is what I came up with
* 2,5 * * *
But this is not working,what seems to be wrong here

Azure Web jobs run multiple times on the provided cron pattern

I have this CRON pattern for my web jobs 0 0/12 20 * * * and it's running every 12 hours starting 8PM. now the problem is that in azure the service run for almost 5 times until 9PM. is there a way that it should only run once?
Your cron expression means it starts from 8pm and every runs 12 minutes. Cause the azure timer binding document couldn't be open for now, you could refer to this wiki: TimerTrigger.
There are six fields {second} {minute} {hour} {day} {month} {day of the week} to schedule.
So in your situation if you want to run every 12 hours starting 8PM. Yo could try this cron: 0 0 20/12 * * * or with this one 0 0 8,20 * * *. One is start from 8pm and every 12 hours and one is run at the specified time.

How to execute a cron expression for every 2.5 min

I want to create a cron expression which will run the scheduler every 2.5 min of every hour. e.g. 2.5min, 5.0min, 7.5min, 10.0min etc. of every hour.
I am using Spring to create the scheduler. I tried various combination but nothing worked. One of them is as below but it is not working.
#Scheduled(cron = "*/30 */2 * * * *")
Thanks in advance.
That should works for you
0 0/5 0 ? * * *
30 2/5 0 ? * * *
At second :00, every 5 minutes starting at minute :00, at 00am, of every day
At second :30, every 5 minutes starting at minute :02, at 00am, of every day
You are right in this case you need to schedule your task twice using expression like on example.
There is a danger of becoming fixated on the 30 seconds. My problem was that I needed to check 18000 records for updates every month ~ 1 record every 2.5 minutes. I spent too much time trying techniques to run a job at exactly 02:32:30 before I realised that accuracy was not important.
In my situation, I realised I could execute every 2 minutes, updating my full database every 25 days instead of every 31 days.
Alternatively, I could have had 2 cron jobs running every 5 minutes. First, a 2-minute gap, followed by a 3-minute gap.
02:30 02:32 02:35 02:37 02:40 02:42 02:45 02:47
My point is that when the cron job is live, it runs unseen. Obviously, everyone has their own specific problem, but before introducing complexity, consider if it is necessary. As long as the job executes, does it really matter the exact time it ran?

jenkins cron job schedule

I wasn't sure how to schedule a job to run from 10 PM to 7 AM (the next day). I was thinking if something like below would work
0 22-8 * * *
Thanks

Resources