ping 60秒


6

我想对IP地址执行ping操作60秒。与Windows中一样,您可以使用-t标志指定时间。

ping 192.168.1.1 -t60

在Linux中可以吗?


1
感谢您的及时答复。我正在发送1000个数据包/秒“ -i 0.001”。所以-c对我不起作用。
mgmihir

1
ping -w超时如何?
John Anderson

如果您是超级用户,则ping速度可以快于0.200
mgmihir

Answers:


21

man ping

   -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.

例如

$ time ping -w60 192.168.1.65 &>/dev/null

real    1m0.001s
user    0m0.008s
sys     0m0.000s

2

超时命令也可以在这里使用。它来自Linux中的Coreutils软件包。该命令将是:

timeout 60 ping google.com

而已。

注意:您可以在此处执行有时间限制的任何命令。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.