JSI Tip 9361. How can I schedule a job to stop and start the Server service, freeing resources on server?


If your server occasionally requires a restart to make it perform better, you may be able to schedule the stop and start of the server service to free resources.

When you stop the server service, those services dependent upon the server service will also stop, and need to be restarted after your restart the server service.

I have scripted SSSrvSvc.bat to:

  • Disconnect any user sessions
  • Stop the Server service and its' dependent services.
  • Start the Server service.
  • Start the dependent services

You should schedule SSSrvSvc.bat to run in an Administrator or System context, probably once a day, at a time when the fewest clients are active.

SSSrvSvc.bat contains:

@echo off
setlocal ENABLEDELAYEDEXPANSION
goto skip
net sess /delete /y
net sess /delete /y
net stop Server /y>"%TEMP%\Server.log" 2>&1
net stop Server /y>>"%TEMP%\Server.log" 2>>&1
net start Server
:skip
for /f "Tokens=1* Delims=:" %%a in ('type "%TEMP%\Server.log" ^|Findstr /l /n /v /c:"*$"^|FIND "   "') do (
 set line=%%b
 net start "!line:~3!"
)
del /q "%TEMP%\Server.log"
endlocal



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish