Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I try to ping a hostname of a computer that is down, I get en error that it cannot resolve the hostname.

$ alice:~ me$ ping bob
ping: cannot resolve bob: Unknown host

Is there a way I can make ping more persistent? I want it to keep trying so I can see when bob comes back online.

share|improve this question
Do you expect the name to resolve when the host comes up? – Ignacio Vazquez-Abrams Dec 15 '10 at 3:40
@Ignacio: Yes, that's what I expect. And it does. – Svish Dec 15 '10 at 18:35
up vote 1 down vote accepted


while true; do
    ping bob || sleep 1


until ping bob; do
    sleep 1

or b) Configure a name resolution method that doesn't rely on the target host being up. /etc/hosts for the lazy.

share|improve this answer
Nice and simple, I like it. – Svish Dec 15 '10 at 18:36
redirect stderr to /dev/null if you don't want unknown host spam – Michael Nov 6 '13 at 19:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.