win按照时间戳每秒执行ping,并追加输出记录文档
@echo off @echo. 请以管理员身份运行 @echo. 终止请按: Ctrl+C set /p host=host: set logfile=%~dp0%host%.txt echo Target Host=%host% >> %logfile% :flag for /f "tokens=* skip=2" %%A in ('ping %host% -n 1') do ( echo %date% %time:~0,-3% %%A>>%logfile% echo %date% %time:~0,-3% %%A timeout /t 1 /nobreak>nul goto flag ) pause>nul
echo Target文件输出处:>是覆盖,>>是追加
%~dp0 为获取当前目录
仅作记录使用
文档数据来源:https://zhuanlan.zhihu.com/p/486173119