Skip to content

Instantly share code, notes, and snippets.

@shoaibi
Created June 25, 2015 15:14
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 shoaibi/e73e84253da488b97356 to your computer and use it in GitHub Desktop.
Save shoaibi/e73e84253da488b97356 to your computer and use it in GitHub Desktop.
Test if a remote port is responding or not. Good to be used as part of cron/script that'd send notifications if a port becomes unresponsive
#!/bin/sh
# Usage: $0 {hostname} {port} {pathToScriptToExecuteIfPortIsNotAccessibleSayRestartApacheScript}
echo "" | nc $1 $2 && echo $? &>> /dev/null || $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment