Set audible alarm when an IP address comes online

ping -i 60 -a IP_address
Waiting for your server to finish rebooting? Issue the command above and you will hear a beep when it comes online. The -i 60 flag tells ping to wait for 60 seconds between ping, putting less strain on your system. Vary it to your need. The -a flag tells ping to include an audible bell in the output when a package is received (that is, when your server comes online).

112
By: haivu
2009-03-04 06:21:22

1 Alternatives + Submit Alt

What Others Think

OSX: ping -i 60 -A IP Instead of a bell you can have OSX tell you (this one will check every 30 seconds for 5 minutes) ping -i 30 -c 10 IP && say -v vicki 'Server is back online'
vaporub · 510 weeks and 1 day ago
Pinging your system isn't putting any "strain" on it at all. 'ping -f' that sucker, and the only "strain" you're putting anywhere is your network.
atoponce · 510 weeks and 1 day ago
@vaporub that will say 'Server is back online' no matter what, regardless of whether or not the ping actually works, and after all pings are done. You are essentially doing: sleep 300; say -v vicki 'Server is back online' albeit with ping working in the mean time. I think you may have missed the concept.
sudopeople · 510 weeks and 1 day ago
@sudopeople No, from the man page: > If ping does not receive any reply packets at all it will exit with > code 1. If a packet count and deadline are both specified, and fewer > than count packets are received by the time the deadline has arrived, > it will also exit with code 1. On other error it exits with code 2. > Otherwise it exits with code 0. This makes it possible to use the exit > code to see if a host is alive or not. Only problem is it will always wait the whole 5 minutes before telling you.
porges · 510 weeks and 1 day ago
Remember about "visual bell" (http://www.faqs.org/docs/Linux-mini/Visual-Bell.html). If you use "visual bell" in your xterm, try: xset b; ping -a IP; xset -b turn off "visual bell" before ping, and turn it on after ping.
unixmonkey2039 · 510 weeks and 1 day ago
@vaporub: good point, it still misses the mark though. Like you said, it will wait 5 min before telling you if it is up. It would work like this: sleep 300; ping -c1 IP && say "server is up" this is a better solution: while true; do [ "$(ping -c1W1w1 server-or-ip.com | awk '/received/ {print $4}')" = 1 ] && say -v vicky "Server is back online" || echo; sleep 1; done It would be annoying as hell, but you'd know it was up. More info: http://www.commandlinefu.com/commands/view/1815/beep-when-a-server-goes-offline
sudopeople · 506 weeks and 2 days ago
The ping command with -o option will exit successfully after receiving one reply packet (at least on Mac OS X): ping -o $ip && say "Server is back online"
jh12z · 246 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

Considering A New Car?

You should consider a Tesla. Get 6 Months Free Supercharging.

Free Supercharging

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: