如何解决 Windows 计划任务未运行? [英] How to troubleshoot Windows Scheduled Task not running?

查看:155
本文介绍了如何解决 Windows 计划任务未运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在部署我们的 .net 应用程序的过程中,我在服务器上设置了大约 20 个计划任务,所有这些任务基本上都做同样的事情:调用一个从 SQL 数据库中提取数据的小型 .net 控制台应用程序并将其发布到 Web 服务.每个任务调用应用程序的一个单独副本,每个副本在其配置文件中具有不同的查找 ID 值.

In the process of deploying our .net app, I've got about 20 scheduled tasks set up on a server, all of which basically do the same thing: invoke a small .net console app that pulls data from a SQL db and posts it to a web service. Each task invokes a separate copy of the app, each copy having a different lookup ID value in its config file.

除了其中两项任务外,所有任务每晚都可靠运行.其中两个任务似乎不时偶尔停止运行,目前尚不清楚原因.当他们停止运行时,计划任务界面会正确显示他们上次运行的日期,该日期比其他在计划时间继续运行的任务晚了一天或更长时间.停止运行的任务不会自行再次运行,尽管被指示按计划每晚运行.事件日志或计划任务界面本身没有记录错误.对我们来说最奇怪的部分是:如果我手动启动计划任务,它运行良好,它调用 .net 控制台应用程序并且一切都没有异常地完成.然后它继续在预定时间正常运行,一次持续数天或数周,但最终失败,似乎是出乎意料.这两个任务似乎总是在同一天晚上开始失败.

All but two of these tasks run reliably every night. Two of the tasks seem to sporadically stop running from time to time, and it's currently a mystery as to why. When they stop running, the scheduled task interface correctly shows their last run date, which is a day or more behind the other tasks, which have continued to run at the scheduled time. The tasks which stopped running do not run again on their own, despite being indicated as scheduled to run every night. There are no errors recorded in the event log or in the scheduled task interface itself. And here's the strangest part to us: If I manually kick off the scheduled task, it runs fine, it invokes the .net console app and everything finishes without anomaly. And then it continues to run fine at its scheduled time, for days or weeks at a time, only to eventually fail, seemingly out of the blue. It appears both tasks always start to fail on the same night.

推荐答案

有一个Last Result"列,它应该为您提供与正在运行的任务本身相关的代码(它不会有任何类型的异常数据).0 表示任务完成且没有错误.您可以查找其他任何内容,看看为什么任务无法启动.如果任务似乎仍未运行,但您仍然看到 Last Result 为 0,这意味着您的代码中存在某些问题,但它正在正常退出.

There's a "Last Result" column that should give you a code related to the task itself running (it's not going to have any kind of exception data). 0 means the task completed without errors. Anything else you can look up and see why the task won't start. If the task still seems to not be running, but you still see a 0 for the Last Result, that means there's something broken in your code, but it's exiting gracefully.

这篇关于如何解决 Windows 计划任务未运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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