Question: I want to write a script, that would keep checking if any of the devices in network, that should be online all day long, are really online. I tried to use ping, but

```
if [ "`ping -c 1 some_ip_here`" ]
then
  echo 1
else
  echo 0
fi

```

gives `1` no matter if I enter valid or invalid ip address. How can I check if a specific address (or better any of devices from list of ip addresses) went offline?

Answer: 
There is advanced version of ping - "fping", which gives possibility to define the timeout in milliseconds.

```
#!/bin/bash
IP='192.168.1.1'
fping -c1 -t300 $IP 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]
then
  echo "Host found"
else
  echo "Host not found"
fi

```
check host every one second and send message when host is reach

```
while :;do ping -c 1 -w 1 -q 8.8.8.8 &>/dev/null && /root/telegram-send.sh "Host reacheble now" && break || sleep 1;done

```