Linux check if server exists by IP and port
Task: Check if server exists by IP and port in the Jenkins Job before connect to it by SSH in the bash script
Solution:
server=192.168.1.1 if nc -z $server 22 2>/dev/null; then echo "$server Ok" # Do some actions.... else echo "$server Fail" # Do some actions.... fi
Done.