Board logo

标题: [系统相关] 批处理如何定时运行邮局服务重启? [打印本页]

作者: rigg    时间: 2015-1-10 12:51     标题: 批处理如何定时运行邮局服务重启?

我的邮局经常发一会就出问题了,需要重启邮局端程序,命令如下:
C:\WINDOWS\system32\net.exe STOP hMailServer
C:\WINDOWS\system32\net.exe START hMailServer
能用BAT写一个定时重启的命令吗
作者: pcl_test    时间: 2015-1-10 13:41

回复 1# rigg

  1. @echo off
  2. ::挂机模式
  3. mode con cols=14 lines=1
  4. :aa
  5. ::每隔5分钟重启hMailServer服务
  6. ping /n 301 127.1>nul
  7. net stop hMailServer
  8. net start hMailServer
  9. goto aa
复制代码

作者: rigg    时间: 2015-1-10 17:06

如果时间间隔要改成2小时呢
作者: rigg    时间: 2015-1-10 17:07

运行的时候能不能以后台模式运行?
作者: DAIC    时间: 2015-1-10 18:31

把重启服务的命令放到任务计划里面比较好
BAT脚本内部死循环的方式太浪费系统资源
作者: yiwuyun    时间: 2015-1-10 19:56

schtasks /create /tn MailServerStop /sc hourly /st 8:00 /tr "net stop hMailServer"
schtasks /create /tn MailServerStart /sc hourly /st 8:01 /tr "net start hMailServer"
作者: yiwuyun    时间: 2015-1-10 20:16

@echo off
schtasks /create /tn MailServerStop /sc daily /ri 120 /du 130 /tr "net stop hMailServer"
ping /n 70 127.0.0.1>nul
schtasks /create /tn MailServerStart /sc daily /ri 120 /du 130 /tr "net start hMailServer"
作者: amwfjhh    时间: 2015-1-10 21:25

可以用JS和BAT混合编码的方式来写批处理,既可以隐藏执行,也可以用jscript的精确sleep来达到延时目的,这比单纯用BAT做延时要节省很多系统资源。




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2