SQL Server Agent Job Timeout -


I had a SQL Server job run that lasted longer than usual, and I actually did a set timeout with Could stop it after a certain period.

I may be a little blind on this, but I can not find any way to set a timeframe for the job. Does anyone know of a way to do this?

Thank you

We do something like a night part of the job processing subsystem The code given below - in reality it is more complex than reality; For example, we are processing many other mandatory sets of jobs, and have read job descriptions and timetable values ​​from configuration tables - but it captures this idea:

  DECLARE @JobToRun NVARCHAR (128) = 'My agent job description @ dtStart DATETIME = GETDATE (), @ dtCurr DATETIME DECLARE @ExecutionStatus INT, @LastRunOutcome INT, @MaxTimeExceeded bit = 0 DECLARE @TimeoutMinutes INT = 180 EXEC msdb.dbo .sp_start_job @JobToRun SET @dtCurr = GETDATE () WHILE 1 = 1 BEGIN WAITFOR DELAY '00: 00: 10 'SELECT @ ExecutionStatus = current_execution_status, @OpenRunOutcome = last_run_outcome from OpenAquac Ri (local surfer, Femtonli off of Feldn; F Msdibi Dibis.aspi_helf_aj ') where [name] = @ Jobtun IF @ execution status & lt; & Gt; 4 BEGIN - Job running or refine (not inactive) SET @ dtCurr = GETDATE () If DATEDIFF (miles, @dtstart, @titcurr) & gt; @TimeoutMinutes BEGIN EXEC msdb.dbo.sp_stop_job @job_name = @jobToRun - Can log information, increase error, send email etc. Finally CONTINUE END END If @LastRunOutcome = 1 - Job just with success flag Finish BEGIN - Job succeeded, print whatever is necessary 'Job Successful' END END  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -