任务调度程序/powershell/超时 [英] Task scheduler / powershell / timeout

查看:66
本文介绍了任务调度程序/powershell/超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我需要每小时运行一个脚本.我在任务调度程序上设置了这些参数,它似乎有效.

I have a website which I need to run a script every hour. I set these parameters on task scheduler and it seems to work.

程序/脚本:powershell.exe

Program/script: powershell.exe

添加参数:-c (new-object system.net.webclient).downloadstring('http://www.example.com/test.ashx')

Add arguments: -c (new-object system.net.webclient).downloadstring('http://www.example.com/test.ashx')

问题是我在这个脚本中有一个大循环和进程,脚本在完成循环之前就停止了!是否有可能添加超时作为参数或其他方法来防止这种情况发生?

The problem is that I have a big loop and processes in this script and the script stops before it finish the loop! Is there any possibility to add a timeout as an argument or something else to prevent this?

我使用的是 Windows Server 2008R2 和 .NET 4

I'm using Windows Server 2008R2 and .NET 4

推荐答案

PowerShell 不会因为超时而提前终止脚本 - 所以这不是问题.最可能的原因是脚本中的某些内容引发了异常,或者任务计划程序可能配置为终止运行时间过长的任务.无论哪种方式,您都可以在事件日志或任务调度程序日志中找到诊断信息.

PowerShell won't terminate a script early because of a timeout - so that isn't the problem. The most likely causes are that something in your script is raising an exception or possibly the Task Scheduler is configured to kill a task that runs too long. Either way, you can probably find the information to diagnose that in the event log or the task scheduler log.

一个容易检查的地方是您创建的任务属性.在设置"选项卡上,有一个选项可以在任务运行时间超过时停止任务" - 您可能已启用该选项并将其设置为 1 小时.

An easy place to check is the task properties you have created. On the Settings tab there is an option to "stop the task if it runs longer than" - you might have that enabled and set to 1 hour.

这篇关于任务调度程序/powershell/超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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