自动重启iisadmin或tomcat的bat脚本

 自动重启iisadmin或tomcat的bat脚本

【转自】http://hi.baidu.com/fququ/blog/item/2204d15c4be5b147faf2c074.html

 

有的时候iis因某些原因停止了工作,用以下小脚本重启它

net stop iisadmin /y
@echo "now restart w3svc"
net start w3svc
net start iisadmin

用C#写个小的运行程序就ok了.呵 :

c# console 代码如下:

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;

namespace RestartIIs
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string frequence = "0";
                Console.WriteLine("请输入重启iis的时间间隔(频率)分钟:");
                frequence = Console.ReadLine();
                int runFre = int.Parse(frequence)*60000;
                while (true)
                {
                    Process pc = new Process();
                    pc.StartInfo.FileName = "restartIIS.bat";
                    pc.Start();
                    Thread.Sleep(10);
                    pc.Close();
                    Thread.Sleep(runFre);
                   
                }
            }
            catch
            {
                Console.WriteLine("发生错误,程序关闭!");
            }
          
        }
    }
}

 

---tomcat 服务版的

net stop "apache Tomcat"
@echo "stop Tomcat ok,now,start Tomcat"
net start "apache Tomcat"
@echo "make all done over"

--tomcat 非服务版的

call "shutdown.bat"
@echo "stop Tomcat ok,now,start Tomcat"
call "startup.bat"
@echo "make all done over"

--加上时间延迟,5秒钟左右再运行启动tomcat :

call "shutdown.bat"
@echo "stop Tomcat ok,now,start Tomcat"
ping 127.0.0.1 -n 5
call "startup.bat"
@echo "make all done over"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值