- Background introduction
The company has a number of Web sites, no configuration monitoring services, every day to check whether the server is working properly. Inefficient and time-consuming.
- Code Snippets
#!/bin/bash# Author Jerry.huang (Email:[email protected]) # Check Web Serverif[[-Z ' curl-i-S"http://www.baidu.com"|grep "OK"` ]]; ThenEcho "www.baidu.com Server server is down"| Mail-s"www.baidu.com Server Alert"[Email protected],616043155@qq. com &&Echo "$ (date) www.baidu.com server is down">>/home/CheckServerError.logElseEcho "$ (date) www.baidu.com server is OK">>/home/WebCheckSuccess.logfi
Add a Scheduled task
Crontab-e
*/10 * * * */usr/local/sbin/checkserverhealth.sh >/dev/null 2>&1
- Please refer to my previous article on the email feature:
Http://www.cnblogs.com/Mrhuangrui/p/4589809.html
Script monitors Web server, does not work properly email reminders