Shell script to check whether a server is reachable?

The most barebones check you can do is probably to use netcat to check for open ports.

to check for SSH (port 22) reachability, you can do

if nc -z $server 22 2>/dev/null; then
    echo "$server ✓"
else
    echo "$server ✗"
fi

from the manpage:

-z   Specifies that nc should just scan for listening daemons, without sending any data to them.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)