Elastic Job Schedule

John Paul Attard 1 Reputation point
2022-02-23T17:21:14.217+00:00

Hi,

I have an elastic Job and I would like to schedule it to run Monday to Friday from 8.00 AM to 5.00 PM.

Any idea how I can do it, please?

Azure SQL Database
0 comments No comments
{count} votes

8 answers

Sort by: Most helpful
  1. Alberto Morillo 32,886 Reputation points MVP
    2022-02-23T17:52:18.257+00:00

    You can try something like this:

    EXEC jobs.sp_update_job
    @job_name='Run Sample Job',
    @enabled=1,
    @schedule_interval_type='Days',
    @schedule_interval_count=1,
    @schedule_start_time='2021-09-21 11:00:00' (sets time to 4:00am PST, adjust time accordingly)
    

    You can also read this article for more detailed information.

    0 comments No comments

  2. John Paul Attard 1 Reputation point
    2022-02-23T18:12:56.26+00:00

    Hi, thanks for the reply :)

    If I understand correctly, this will run the job every day at 11:00 am?

    Because what I'm trying to achieve is to run the job Monday to Friday, every 5 minutes between 8.00 AM and 5.00 PM.

    With the on-prem SQL server agent, this was easily done, now I want to replicate this on an azure elastic job agent database instance.

    0 comments No comments

  3. Oury Ba-MSFT 16,081 Reputation points Microsoft Employee
    2022-02-23T22:19:42.11+00:00

    Hi @John Paul Attard Thank you for posting your question on Microsoft Q&A and for using Azure services.

    You are trying to schedule job to run Monday to Friday from 8.00 AM to 5.00 PM.

    In addition to Alberto Morillo's answer Elastic Jobs can target Azure SQL Databases, Azure SQL Database elastic pools, and Azure SQL Databases in shard maps.

    177279-image.png

    177332-image.png

    https://techcommunity.microsoft.com/t5/azure-sql-blog/running-scheduling-and-monitoring-elastic-jobs-in-azure-sql/ba-p/1180179

    Regards,
    Oury

    0 comments No comments

  4. John Paul Attard 1 Reputation point
    2022-02-24T06:22:32.1+00:00

    Hi @Oury Ba-MSFT , thanks for the snippets. :)

    I have just one thing to clarify.

    This is my test:

    @schedule_interval_type = 'Minutes',
    @schedule_interval_count = 15,
    @schedule_start_time='2022-02-22 08:00:00',
    @schedule_end_time='2022-02-23 17:00:00';

    If I understood correctly, @schedule_start_time / @schedule_end_time are fixed datetime2 variables.

    So, this means that the jobs will keep running for 24 hours between the specified start/end time.

    Thanks, and apologies for the questions.

    0 comments No comments

  5. Oury Ba-MSFT 16,081 Reputation points Microsoft Employee
    2022-02-24T21:05:50.507+00:00

    @John Paul Attard

    In this case it will be executed every 15 minutes from “@schedule_start_time” to “ @schedule_end_time”. Interval count is number of intervals of the “interval type”. If the type is “hours” it will execute every 15 hours from the start time till the end time.
    @schedule_interval_type = 'Minutes',
    @schedule_interval_count = 15,

    Hope this helps

    Please do not forget to mark as accept answer if the reply was helpful

    Regards,
    Oury

    0 comments No comments