IISを定期的に再起動させたい!! - MONO*LOG

IISを定期的に再起動させたい!!

WindowsのIIS...セキュリティホールなどで悪名高いが、IISで運用されているサービスは意外と多い。
このIIS、IIS6.0ではかなり高機能になっていてプロセスの監視機能やメモリ管理なんかもかなり充実している。

IIS5.0の場合、IIS6.0のようなプロセス監視機能がないため、特定のアプリケーションがメモリヒープを起こした場合に対応が難しい。
こういった場合には「IISRESET」コマンドが非常に役に立つ。
/RESTART オプションを /REBOOTONERROR と /TIMEOUT オプションと併用することによって、「IISの再起動に一定時間失敗したらOSを再起動する」ということができる。

早速、テキストエディタを開き、「c:\iis_restart.bat」として保存する。

iisreset /RESTART /REBOOTONERROR /TIMEOUT:30 対象のホスト名


あとは、たとえば1時間おきにIISの再起動を行いたいのであれば、ATコマンドで以下のジョブを追加する。

C:\>at 0:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 1:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 2:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 3:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 4:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 5:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 6:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 7:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 8:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 9:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 10:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 11:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 12:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 13:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 14:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 15:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 16:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 17:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 18:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 19:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 20:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 21:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 22:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"
C:\>at 23:00 /every:M,T,W,Th,F,S,Su "c:\iis_restart.bat"

コメントする

アーカイブ

Music