Last active
December 22, 2015 18:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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