N
N
NeoLight32020-09-07 17:11:51
cmd/bat
NeoLight3, 2020-09-07 17:11:51

How to make a .bat script that would automatically restart the "Not responding" server application?

I have a server application, the server may hang, Windows shows it as an application not responding.
Is it possible to somehow make a .bat script that would automatically restart such an .exe application?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2020-09-09
@MAD-Kuzia

Try something like:

@ECHO OFF
:CHECK
TASKLIST /NH /FI "IMAGENAME EQ CALC.EXE" /FI "STATUS EQ RUNNING" | FIND /I ":" > NUL
IF %ERRORLEVEL%==0 GOTO NOT_RUNNING
TIMEOUT /T 300 /NOBREAK
GOTO CHECK
:NOT_RUNNING
TASKKILL /IM CALC.EXE /T /F
START CALC.EXE
TIMEOUT /T 10 /NOBREAK
GOTO CHECK

It is assumed that there is only one server instance (calculator in the CALC.EXE example) running, otherwise it is necessary to check/shoot not by IM (process name) but by its PID.

V
Viktor Sirotin, 2020-09-17
@visirok

Run your server under Kubernetes and check the survivability of the server in your own way.
It is not joke. Installing Kubernetes is easy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question