w后面单位为秒。
-w deadline
Specify a timeout, in seconds, before ping exits regardless of how many packets have been sent or received. In this case ping does not stop after count packet
are sent, it waits either for deadline expire or until count probes are answered or for some error notification from network.
-W timeout
Time to wait for a response, in seconds. The option affects only timeout in absence of any responses, otherwise ping waits for two RTTs.
追问哦,我说的windows系统。 windows系统上怎么用呢?
其实我就想实现不停地ping个ip, 当延迟高于一定值时,执行一段命令。
我手上没有windows环境,可以写个循环,不停的检查ping的结果,假如时延达到一定程度,就执行命令。执行完可以跳出循环,也可以继续循环。
刚网上找了一位同学写的代码,你可以参考下。他也用了-w参数,估计超时会导致命令errorlevel为1,就报错。