-
-
Save Hemanthdev/cce8640a33e7aaec2a2cac0cdd57dcf7 to your computer and use it in GitHub Desktop.
Check if Apache is running, and if not, restart it
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/sh | |
| PORT=80 | |
| HP=:$PORT | |
| echo 'Checking to see if Apache is up...' | |
| if ( /usr/sbin/lsof -Pni $HP | grep "$PORT (LISTEN)" 2>&1 >/dev/null ); then | |
| echo 'Apache is up'; | |
| else | |
| echo 'Apache is down, restarting...'; | |
| /sbin/service httpd restart | |
| logger -p mail.info apache_check_restart.sh restarting Apache | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment