Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 SQL Server Agent Jobs Stuck

Author  Topic 

Starlet_GT
Yak Posting Veteran

81 Posts

Posted - 2011-08-04 : 01:56:39
Hi,

I am facing a issue which I need to know how to overcome. I got few jobs which are scheduled to run after every one hour, but unfortunately jobs didn't completed and are pretended to be running when we check the job status. Although I have developed a mechanism through which if a job failed it intimate me but in this case when job is still running I didn’t know about the status until someone tells me that they are not getting required data through system. And then I have to stop it forcefully and re-run it. It happened once in a month but it is unusual.

I want a query or something through which if a job keeps on running after 5 hours it should be automatically killed.

Please help.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-04 : 08:53:28
you can add a separate job which gets fired at convinient time and it need to check sysjobhistory table in MSDB databse to ensure if job is running and if yes it needs to call sp_stop_job sp to stop the job.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Starlet_GT
Yak Posting Veteran

81 Posts

Posted - 2011-08-05 : 03:17:10
Thanks for your response. could you please provide me the query which filter out jobs running continus for two hours and stop execute stop job at the same time.

Thanks in adv.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-08 : 04:36:48
see

http://thecrankydba.com/2009/09/08/using-sysjobhistory-to-find-whats-running-longer-than-usual/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -