Skip to content

Instantly share code, notes, and snippets.

@SamRothCA
Created October 30, 2014 20:51
Show Gist options
  • Save SamRothCA/1537bf368e9a13b7aa5f to your computer and use it in GitHub Desktop.
Save SamRothCA/1537bf368e9a13b7aa5f to your computer and use it in GitHub Desktop.
Test if a server is online
ping -c1 -t3 example.com &> /dev/null
@gellis12
Copy link

If the server in question is behind a modem our router or something (like most home servers), this will only tell you if the router/modem is online. Netcat would normally be more ideal, like this:

nc -zG 3 -L 5 example.com 22 &> /dev/null

This checks to see if there is anything listening in port 22 (standard SSH port) on the server you're testing. It will wait up to 3 seconds per attempt before it times out, and it will make 5 total attempts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment