Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help rewrite this batch file

Status
Not open for further replies.
Oct 9, 2003
174
US
I have this script that someone on this board helped me wirte (thanks wallst32) but when its run on the server its is very taxing on the dual processors. It sends the processors into a high state of utilization. From 5%-10% to 70%-80% on avg. Can anyone help to rewrite this to make it more efficent or suggest some modifications that I can make to it.

The whole point of writing this in the first place was that the connection between our two mail servers were timing out occasionally. I wanted to get a feel for the amount of down time. Below is the scritpt, thanks.

********************************************
:begin
ping -n 1 xxx.xxx.xxx.xxx | find /i "reply"
if errorlevel 1 goto noreply
if errorlevel 0 goto reply

:reply
goto repeat

:noreply
ECHO DOWN @ %DATE% --- %TIME% >> log.txt
goto noreplyloop

:repeat
goto begin

:noreplyloop
ping -n 1 xxx.xxx.xxx.xxx | find /i "reply"
if errorlevel 1 goto noreplyloop
if errorlevel 0 goto replyloop

:replyloop
ECHO UP @ %DATE% --- %TIME% >> log.txt
ECHO " " >> log.txt
ECHO " " >> log.txt
goto repeat

:end
**********************************************
 
put a sleep command in there. so that the server waits a minute or two

:begin
:: sleep for two minutes
sleep 120
ping -n 1 xxx.xxx.xxx.xxx | find /i "reply"
if errorlevel 1 goto noreply
if errorlevel 0 goto reply

and here
:noreplyloop
:: sleep for two minutes
sleep 120
ping -n 1 xxx.xxx.xxx.xxx | find /i "reply"
if errorlevel 1 goto noreplyloop
if errorlevel 0 goto replyloop

should help in stopping the runaway loop

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top