本文共 3140 字,大约阅读时间需要 10 分钟。
说到Domino的维护,相信广大管理员都有同感,非常的头痛,不管是从管理或者排错上都比较麻烦,我就说说我的亲身感受吧~由于我们使用的是windows2012r2+domino9环境,然后注册的用户又比较多,由于windows系统不经常重启,服务器资源—比如内存就满了,这样就导致用户收发邮件慢。所以作为管理员需要定期对domino进行重启。我们都知道对domino进行重启前,我们需要将windows 上的domino服务停止,然后再对windows系统进行shutdown –r –t 的操作。系统重启后,domino服务会随着系统的启动而启动。但是启动后或者使用过程中有可能某个服务自动停止也会给管理员的工作压力。所以我们也同样使用脚本近期定期的判断。来保证服务的正常运行。脚本定义好后,我们通过系统自带的计划任务来根据自己的需求执行即可,具体见下:
首先是Domino服务的重启维护
我们通过脚本首先通过nserver将domino服务停止----quit的操作。等待domino服务结束后,然后直接系统的shutdonw –r –t 重启的工作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | Do Call CloseProcess( "nserver.exe" ,1) Loop While IsProcess( "nserver.exe" )=True '结束进程 Sub CloseProcess(ExeName,RunMode) dim ws Set ws = createobject( "Wscript.Shell" ) 'ws.run "cmd.exe /C Taskkill /f /im " & ExeName,RunMode ws.run "cmd.exe /C D:\IBM\Domino\nserver.exe -c quit" '如果nserver.exe所在的目录有空格,就需要通过8.3规则进行转换,' 比如我们将domino安装到默认(C:\program files\ibm\domino\nserver.exe) '此时我们需要将以上命令修改,将ws.run "cmd.exe /C C:\Program files\IBM\Domino\nserver.exe -c quit" 为ws.run "cmd.exe /C C:\Progra~1\IBM\Domino\nserver.exe -c quit" wscript. sleep 60*1000 '延迟1秒 ws.run "cmd.exe /C shutdown /r /t 0" Set ws = Nothing End Sub '检测 Function IsProcess(ExeName) Dim WMI, Obj, Objs,i IsProcess = False Set WMI = GetObject( "WinMgmts:" ) Set Objs = WMI.InstancesOf( "Win32_Process" ) For Each Obj In Objs If InStr(UCase(ExeName),UCase(Obj.Description)) <> 0 Then IsProcess = True Exit For End If Next Set Objs = Nothing Set WMI = Nothing End Function |
上面是domino服务停止及系统重启的过程,接下来我们介绍,如果系统启动后,发现domino服务没有启动的问题,我们也同样适用vbs脚本来定时启动。
1 2 3 4 5 6 7 8 9 10 11 | Dim WshShell, ProgramPath ProgramParentPath="d:\IBM\Domino\" ProgramPath=ProgramParentPath & "nserver.exe" Set WshShell=WScript.CreateObject( "WScript.Shell" ) WshShell.CurrentDirectory=ProgramParentPath Set wmiService = GetObject( "winmgmts:\\.\root\cimv2" ) Set wmiObjects = wmiService.ExecQuery( "SELECT * FROM Win32_process where name='nserver.exe'" ) If wmiObjects.count = 0 Then WshShell.Run "cmd.exe /c " & Chr(34) & ProgramPath & Chr(34) & "" ,0 WScript.Quit End If |
启动脚本也有了,那如果在使用过程中http、pop3、smtp等服务停止了,如果通过脚本启动呢?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | if IsProcess( "nserver.exe" ) then Call CloseProcess( "nserver.exe" ,1) End If '加载服务 Sub CloseProcess(ExeName,RunMode) dim ws Set ws = createobject( "Wscript.Shell" ) 'ws.run "cmd.exe /C Taskkill /f /im " & ExeName,RunMode ws.run "cmd.exe /C D:\IBM\Domino\nserver.exe -c " & "" "" & " load http" & "" "" ws.run "cmd.exe /C D:\IBM\Domino\nserver.exe -c " & "" "" & " load pop3" & "" "" ws.run "cmd.exe /C D:\IBM\Domino\nserver.exe -c " & "" "" & " load smtp" & "" "" Set ws = Nothing End Sub '检测 Function IsProcess(ExeName) Dim WMI, Obj, Objs,i IsProcess = False Set WMI = GetObject( "WinMgmts:" ) Set Objs = WMI.InstancesOf( "Win32_Process" ) For Each Obj In Objs If InStr(UCase(ExeName),UCase(Obj.Description)) <> 0 Then IsProcess = True Exit For End If Next Set Objs = Nothing Set WMI = Nothing End Function |
最后我们只需要运行 taskschd.msc 打开系统自带的计划任务管理器来新建计划任务即可:
1 | taskschd.msc |
本文转自 高文龙 51CTO博客,原文链接:http://blog.51cto.com/gaowenlong/1684507,如需转载请自行联系原作者