Task scheduler / powershell / timeout

妖精的绣舞 提交于 2021-02-11 17:22:14

问题


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.

Program/script: powershell.exe

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?

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


回答1:


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.

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.

Task Scheduler Settings




回答2:


There's another gotcha: Go into the Trigger and you'll find another place Windows can kill your Task.



来源:https://stackoverflow.com/questions/18932130/task-scheduler-powershell-timeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!