如果 SQL Server 作业已经在运行,它是否会跳过计划的运行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/865042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:04:03  来源:igfitidea点击:

Will a SQL Server Job skip a scheduled run if it is already running?

sqlsql-serverscheduled-taskssql-server-agent

提问by Sam Schutte

If you schedule a SQL Server job to run every X number of minutes, and it does not finish the previous call before the # of minutes is up, will it skip the run since it is already running, or will it run two instances of the job doing the same steps?

如果您安排一个 SQL Server 作业每 X 分钟运行一次,并且它在分钟数结束之前没有完成上一次调用,它会跳过运行,因为它已经在运行,还是会运行两个实例?工作做同样的步骤?

回答by Jose Basilio

The SQL Server agent checks whether the job is already running before starting a new iteration. If you have long running job and its schedule comes up, it would be skipped until the next interval.

SQL Server 代理会在开始新的迭代之前检查作业是否已在运行。如果您有长时间运行的作业并且它的时间表出现,它将被跳过,直到下一个间隔。

You can try this for yourself. If you try to start a job that's already running, you will get an error to that effect.

你可以自己试试这个。如果您尝试启动一个已经在运行的作业,您将收到相应的错误。

回答by PQW

I'm pretty sure it will skip it if it is running.

如果它正在运行,我很确定它会跳过它。

回答by Tom H

Which version of SQL Server are you using? This seems like a pretty easy thing to test. Set up a job with a WAITFOR in it that inserts a single row into a table and set up the job to run twice in quick succession (shorter than the WAITFOR DELAY).

您使用的是哪个版本的 SQL Server?这似乎是一件很容易测试的事情。设置一个带有 WAITFOR 的作业,将单行插入到表中,并将该作业设置为快速连续运行两次(比 WAITFOR DELAY 短)。

When running such a test in SQL Server 2005 it skipped the run that was overlapped.

在 SQL Server 2005 中运行此类测试时,它会跳过重叠的运行。