任务调度程序/powershell/超时

编程入门 行业动态 更新时间:2024-10-11 15:18:10
本文介绍了任务调度程序/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.webclient).downloadstring('www.example/test.ashx')

Add arguments: -c (new-object system.webclient).downloadstring('www.example/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/超时

本文发布于:2023-11-25 13:04:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   powershell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!