持续ping ip或者域名并且加上时间戳,用于监控网络

@echo off
set /p host=host:
set logfile=ping_%host%.log
echo Target Host=%host% > %logfile%
:loop

for /f "tokens=* skip=2" %%A in ('ping %host% -n 1') do (

echo %date:~0,-3% %time:~0,-3% %%A>>%logfile%

echo %date:~0,-3% %time:~0,-3% %%A

timeout /t 1 /nobreak>nul

goto loop

)

pause>nul

  将代码保存为bat文件,运行之后输入需要ping的ip地址或者网址即可。

 

posted @ 2021-11-15 16:40  迷神图卷  阅读(355)  评论(0编辑  收藏  举报