Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
Do you expect the name to resolve when the host comes up? –  Ignacio Vazquez-Abrams Dec 15 '10 at 3:40
1  
@Ignacio: Yes, that's what I expect. And it does. –  Svish Dec 15 '10 at 18:35

1 Answer 1

up vote 1 down vote accepted

a)

while true; do
    ping bob || sleep 1
done

or

until ping bob; do
    sleep 1
done

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

 
discard

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.