ping with timeout bash

Hi experts:

I want to do below thing with bash
if ping 192.168.0.1 sucussful then do somthing without delay, if ping failed within 20s, then kill ping and exit

not sure this can use "alarm" to do this.

any code will be welcome

Thanks

Read your ping man page. Look for the option to specify a timeout/deadline.

Regards,
Alister

1 Like