Windows计划任务,以编程方式检测故障
我想开发一个监视器来检测失败的计划任务和运行时间超过“x”分钟的任务。我正在寻找探测任务状态并检测故障代码(或接收运行状态)的想法。我还想验证“x 小时后停止运行”设置。
I'd like to develop a monitor to detect failed scheduled tasks and tasks that have run for over 'x' minutes. I'm looking for ideas to probe status of tasks and detect a failure code (or receive a status of running). I'd also like to verify the "stop running after 'x' hours" setting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让计划任务在数据库中记录其开始时间、结束时间和结束状态。您需要做的就是查询起始表和结束表中的最新条目以了解当前状态。作为奖励,它会给你一段历史。
Have the scheduled task log its start time, end time, and end status in a database. All you need to do is query for the latest entries in the start and end tables to know the current status. As a bonus it gives you a history.