Restart SQL Agent Task(s) on reboot of server.

  • I have a few SQL Agent tasks that I want to auto run if the server is rebooted.

    Here is the order I am looking for this to occur in.

    1) Server is rebooted, the

    2) SQL Service(s) starts

    3) SQL Agent starts

    4) Fire off specific task(s)

    I have a couple of ideas on how to do this, but I am looking for suggestion/recommendation on how others have accomplished this.

    Teekay

  • THere is an option when creating a SQL Server Agent Schedule to have a job run whenever SQL Server Agent starts. This seems like what you want.

    Jack Corbett
    Consultant - Straight Path Solutions
    Check out these links on how to get faster and more accurate answers:
    Forum Etiquette: How to post data/code on a forum to get the best help
    Need an Answer? Actually, No ... You Need a Question

  • Thanks Jack...

    I now see that I can auto start in the "Scheduling" of a task when the SQL Server Agent Starts.

  • I had issues in my old place in SQL Server 2000 in jobs that are run automatically when Agent starts. The best I can remember is sometime a auto start job would fail saying SQL was not yet ready to process the required action. I got over this by inserting a new step 1 that just did a T-SQL WAITFOR DELAY '00:02:00', giving SQL time to complete its startup processing.

    SQL Agent will start while the database engine is still performing startup actions on user databases. If your auto-start job wants to access one of these DBs, it could hit a problem, hence the wait before starting the work you want to do.

    Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply