IIS应用程序池自动回收作业

vb:

appPoolName = WScript.Arguments(0)

Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")

Set oAppPool = oWebAdmin.Get("ApplicationPool.Name='" + appPoolName + "'")

oAppPool.Recycle

set fso=createobject("scripting.filesystemobject")

if (fso.fileexists("C:\WebRoot\WebSite\FLFTask\Logs\recycleIISPool.log")) then

   '1-forreading,2-forwriting,8-appending

   set file=fso.opentextfile("C:\WebRoot\WebSite\FLFTask\Logs\recycleIISPool.log",8,ture)

else

   set file=fso.createtextfile( "C:\WebRoot\WebSite\FLFTask\Logs\recycleIISPool.log",8,ture)

end if

'write(x)写入x个字符,writeline写入换行,writeblanklines(n)写入N个空行

file.writeline  now&" 应用程序池“"&appPoolName &"”已经回收成功。"

file.close

并写bat

cscript recyclepool.vbs EduWebApi

并放入任务计划程序中 执行Bat

 追加:

回收之后,但还是解决不了,回收第一次的请求卡,再追加一个Bat,调起url请求访问,借用curl实现:

@echo off
color 1f
echo 正在调起程序

echo.>>check.txt
echo.正在调起程序 %date% >>check.txt

echo 开始执行baidu.com   %date% %time% >>check.txt
curl -s http://www.baidu.com/api/Common/CheckProveStatus>>check.txt
echo. 执行完成  %time% >>check.txt

 

posted @ 2017-12-29 21:47  Shikyoh  阅读(1134)  评论(0编辑  收藏  举报