Skip to content

Instantly share code, notes, and snippets.

@acsrujan
Last active July 18, 2016 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acsrujan/8e6d005023c6740ab0ab93db52cc0aa8 to your computer and use it in GitHub Desktop.
Save acsrujan/8e6d005023c6740ab0ab93db52cc0aa8 to your computer and use it in GitHub Desktop.
Script to test connection of a host, port and print time taken for each connection. Output is STDOUT.
#!/bin/bash
START=`date +%s`
while [ $(( $(date +%s) - 30 )) -lt $START ]; do
{ time nc -zw30 <host ip> <port>;} |& grep real | awk '{print $2}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment