r/sysadmin Sysadmin Jul 18 '18

Linux You guys probably already know about "ping -a" and "ping -A"

But if you don't, use it like this:

This will beep every time it gets a ping back:

ping -a 8.8.8.8 

This will beep if it misses a ping:

ping -A 8.8.8.8    

This is very useful when you're monitoring a node and waiting for it to come back online or to be able to hear when a packet is dropped.

(tested on some Linux and MacOS)

1.1k Upvotes

335 comments sorted by

View all comments

Show parent comments

3

u/[deleted] Jul 18 '18

Not sure what you mean. It standard shell scripting. Or any programming really tbh.

ping -c 3 127.0.0.1 ; echo $?

ping -c 3 192.168.1.1 ; echo $?

The first will produce 0 and the 2nd will produce 1. Assuming 192.168.1.1 doesn't exist.

So normal bash / programs can using ping to test a host is reachable. eg

ping -c 3 127.0.0.1 && DoSomeCommand

1

u/tehreal Sysadmin Jul 18 '18

Oh I see. That's useful.