Check for server presence or absence in a batch file?

Do I need to check if the server is installed or not? If down, then I need to send an email And this task should be repeated every 30 minutes.

I need to do this using a batch file.

+3
source share
3 answers

This batch file will get you most of the way. You will need to use blat or something similar or a Windows script to send email. Use the task scheduler to invoke the batch file every 30 minutes.

checkserver.bat:

@echo off
ping -n 1 %1 > NUL
IF ERRORLEVEL 0 (echo "Up -- Don't send email.") ELSE echo "Down -- Send email."

Call it like this:

C:\>checkserver 127.0.0.1  
"Up -- Don't send email."

C:\>checkserver 128.0.0.1  
"Down -- Send email."
+6
source

ping, IP-. , CMD.

0

To check if the server is running, you can use the command ping. To send an email, you can download email tools such as blatetc. To repeat every 30 minutes, configure it using the task scheduler.

0
source

Source: https://habr.com/ru/post/1769178/