Skip to content

Instantly share code, notes, and snippets.

@ph-One
Last active December 22, 2015 18:39
Show Gist options
  • Select an option

  • Save ph-One/6514611 to your computer and use it in GitHub Desktop.

Select an option

Save ph-One/6514611 to your computer and use it in GitHub Desktop.
A shell script example of how to check if your servers are up (the quick 'n dirty way.) Provided an example of how to check both an HTTP server, and an FTP server.Use `crontab` to automate this scripts execution.
#!/bin/bash
# Setup a cron job to check on your servers every 5 minutes. #
# #
# crontab -e #
# */5 * * * * /path/to/checkServers.sh #
# #
# HTTP
ping -c1 -W1 kylematheny.com || notify-send 'kylematheny.com IS DOWN!!'
curl -k --silent https://somedomain:8080 > /dev/null || notify-send "somedomain Application IS DOWN!!"
# FTP
wget --spider --timeout=3 --tries=2 ftp://someftpserver.com > /dev/null 2>&1
if [[ $? -ne 6 ]]
then
notify-send 'FTP Server is offline'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment