关于ping的次数,linux和windows下得写法,ping的时候不输出
1.限制ping次数
windows、下默认不设置次数的情况下是ping4次。
- C:\Documents and Settings\linqt>ping 127.0.0.1 -n 5
- Pinging 127.0.0.1 with 32 bytes of data:
- Reply from 127.0.0.1: bytes=32 time<1ms TTL=64
- Reply from 127.0.0.1: bytes=32 time<1ms TTL=64
- Reply from 127.0.0.1: bytes=32 time<1ms TTL=64
- Reply from 127.0.0.1: bytes=32 time<1ms TTL=64
- Reply from 127.0.0.1: bytes=32 time<1ms TTL=64
- Ping statistics for 127.0.0.1:
- Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 0ms, Average = 0ms
- C:\Documents and Settings\linqt>
想让windows下一直ping可以
- ping 127.0.0.1 /t
- 或者
- ping 127.0.0.1 -t
linux下不设置次数,一直ping。
- [root@tc28 ~]# ping 127.0.0.1 -c 5
- PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
- 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.044 ms
- 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.042 ms
- 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.039 ms
- 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.044 ms
- 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.043 ms
- — 127.0.0.1 ping statistics —
- 5 packets transmitted, 5 received, 0% packet loss, time 4000ms
- rtt min/avg/max/mdev = 0.039/0.042/0.044/0.006 ms, pipe 2
- [root@tc28 ~]#
2.ping的时候不显示ping过程信息
- windows和linux下都是在后面加 >nul
- windows下
- C:\Documents and Settings\linqt>ping 127.0.0.1 -n 5 >nul
- C:\Documents and Settings\linqt>
- linux下
- [root@tc28 ~]# ping 127.0.0.1 -c 5 >nul
- [root@tc28 ~]#