没有作业正在运行时,如何自动停止SQL Server代理? [英] How to automatically STOP SQL Server Agent when no jobs are running?

查看:241
本文介绍了没有作业正在运行时,如何自动停止SQL Server代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个实例中大约有40个不同的sql服务器作业。他们都有不同的时间表。有些每天运行一次,每两分钟运行一次,每五分钟运行一次。如果需要停止SQL Server代理,如何在没有作业在运行时找到最佳时间,这样我就不会中断任何作业?

I have around 40 different sql server jobs in one instance. They all have different schedules. Some run once a day some every two mins some every five mins. If I have a need to stop sql server agent, how can I find the best time when no jobs are running so I won't interrupt any of my jobs?

推荐答案

问题标题让我有些害怕-我认为您想以编程方式在没有作业的情况下关闭SQL Server代理运行。我对这个问题的回答是为什么?

The question title scared me a bit - I thought you wanted to programmatically shut the SQL Server agent down anytime there were no jobs running. My answer to that question would be "Why?" There is no need to.

但是如果您只是想按计划进行重新启动或关闭操作,并且没有像Sentry One的SQL Sentry这样的第三方工具,为了使事件管理器具有可视化效果,我只是在这里让SQL Server代理作业历史记录和作业活动监视器提供帮助。 作业活动监视器可以在状态列中显示当前正在运行的作业。您还可以查看上次执行和下一次执行的日期和时间。

But if you are just looking to do a planned restart or shut down and you don't have a third party tool like Sentry One's SQL Sentry Event Manager to have a visualization, I would just let the SQL Server Agent Job History and Job Activity Monitor help here. The Job Activity monitor can show you which jobs are running right now in the status column. You can also see the last execute and next execute dates and times.

在SSMS的对象浏览器中,连接到您的实例,然后展开SQL Server代理,然后您将看到Jobs,在其下您将看到 Job Activity Monitor -此视图应显示您的需求。

In the object browser in SSMS, connect to your instance, then expand SQL Server Agent, then you'll see Jobs and under that you'll see "Job Activity Monitor" - this view should show you what you need.

此外-不必担心在作业执行前关闭。如果这样做,您可能会丢失该作业的时间表,并且可以根据其需要(取决于该作业及其目的)让它在下一个作业时运行,也可以手动右键单击并执行该作业。

Also - don't worry about shutting down before a job executes. If you do that, you will either have that job just missing its schedule and you can let it run when it is next due to (depending on the job and its purpose) or you can manually right click and execute the job.

有关作业的活动监视器的更多信息,请参见监控器作业活动在产品文档中。

For more on the activity monitor for jobs, see Monitor Job Activity in the product documentation.

这篇关于没有作业正在运行时,如何自动停止SQL Server代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆