Sql server agent job question - maximum run time



  • How long can a SQL server agent job can run in general? are there any maximum run time limit settings option while creating a job ?



  • Out of the box, the SQL Server Agent Job will run continuously until it's completed. There is no maximum runtime or timeout option on the Job itself.

    If you need a way to enforce a maximum runtime, you can use a second Job that monitors for the runtime of your first job, and calls https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-stop-job-transact-sql?view=sql-server-ver15 against it, to instruct the Agent to stop that Job. Depending on the process that is being executed this may stop the Job immediately or it may need to wait for the process to reach a stable point before it can actually stop the Job.

    For more information on stopping a Job, please see the Microsoft docs on https://docs.microsoft.com/en-us/sql/ssms/agent/stop-a-job?view=sql-server-ver15 . Additionally, for more information on the Agent, please see the Microsoft docs https://docs.microsoft.com/en-us/sql/ssms/agent/sql-server-agent?view=sql-server-ver15 .




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2