计划任务时间变化 [英] Schedulled task time varience

查看:101
本文介绍了计划任务时间变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我将某些自动化安排为在特定时间段运行,例如从凌晨3点开始.该自动化程序计划每2小时运行一次.这种自动化运行程序的exe,该程序从数据库中获取记录,并通过邮件将此记录发送给用户.

这种自动化的问题在于,该自动化通常需要60分钟才能执行,但有时需要5、6、10个小时才能执行,因此下一个小时的通知将不会发送.当我运行相同的自动化并具有相同的sp时,为什么仍会发生这种情况?我已经检查了sp是否正常运行.
有人帮我摆脱它吗?或向我建议解决方案,以便如果花费超过2个小时就可以终止该进程并启动下一个实例.

谢谢,
Umesh Tayade

Hi,

I have certain automation that are schedulled to be run at specific time period like it starts in the morning 3 AM. This automation is schedulled to be run after every 2 hour. This automation run the exe of the program that fetches the record from the database and send this records through the mail to users.

The problem with this automation is that this automation generally should take 60 min to execute but sometime it takes 5,6,10 hrs to execute so that the notification for the next hours will not be send. As i m running the same automation and having the same sp still why this happens? I have checked the sp it is running properly.
do anyone help me to get rid of it? or suggest me the solution so that i can kill the process if it is taking more than 2 hrs and start the next instance.

Thanks,
Umesh Tayade

推荐答案

您可以使用Process.Kill方法终止进程.

http://msdn.microsoft.com/en-us/library/t71a733d (v = vs.80).aspx [
You can kill a process using the Process.Kill method.

http://msdn.microsoft.com/en-us/library/t71a733d(v=vs.80).aspx[^]

The following is a more detailed example but in essence the code is:

using System.Diagnostics;
Process[] processes = Process.GetProcessesByName(processName, machineName);
foreach(Process process in processes)
{
  process.Kill();
  process.WaitForExit();
}



http://weblogs.asp.net/stanleygu/archive/2010/03/31/tip-13-kill-a-process-from-local-to-remote.aspx [



http://weblogs.asp.net/stanleygu/archive/2010/03/31/tip-13-kill-a-process-from-local-to-remote.aspx[^]

Although killing processes is not a good practice. Especially if it''s your process. You could decide on some type of exit pointer. Perhaps specific content in an SQL table row or a text file. If you want the running process to stop, set the pointer, the running process, when it detects the pointer, exits nicely from what ever it is doing.


这篇关于计划任务时间变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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