I have a web application that runs through thousands of IP addresses and checks if they're online. Basically, if a server uses more than 250ms to respond, it's considered offline in our case. It would be an enormous timesaver if we could get the ping command to give up after about 300 ms, instead of what seems to be the minimum value of the -W parameter, 1 second.
Found a similar question out there, and the answer was a ping alternative called fping. Maybe it'll be of some use to you. https://serverfault.com/questions/200468/how-can-i-set-a-short-timeout-with-the-ping-command
From the man pages on ping it looks as though it is the -o to send only 1 packet...
ping -W 250 -o
That should return much more quickly also the -W parameter is in milliseconds, so that should send 1 packet and only wait 250ms for a response.
EDIT You Sure?:
$ ping -W 250 -o google.com PING google.com (22.214.171.124): 56 data bytes 64 bytes from 126.96.36.199: icmp_seq=0 ttl=51 time=18.850 ms --- google.com ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 18.850/18.850/18.850/0.000 ms
Running on Mac Maverick. Pings 256 addresses in 39 seconds, i.e., 151ms / ping.
$cat netcheck i=255 while test $i -ge 0 do address=192.168.1.$i if ping -i .1 -c 1 -W 50 $address > /dev/null then echo $address fi let i=$i-1 done $time ./netcheck 192.168.1.255 192.168.1.254 192.168.1.241 192.168.1.216 192.168.1.174 192.168.1.148 192.168.1.108 192.168.1.102 192.168.1.0 real 0m38.653s user 0m0.369s sys 0m0.616s $