Created
March 22, 2018 07:52
-
-
Save goodjack/39d62fd105c1ebc69b651ca258d3f471 to your computer and use it in GitHub Desktop.
Check PhpBrew PHP-FPM, auto restart PHP-FPM if it is down.
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 | |
| source ~/.bashrc | |
| port='9001' | |
| check=$(netstat -na | grep "LISTEN" | grep "$port" | awk -F[:" "]+ '{print $5}') | |
| if [[ "$check" != "$port" ]]; then | |
| { | |
| echo "PHP-FPM is down, restarting... $(date +"%F %T")" | |
| service phpbrew-fpm restart | |
| echo "PHP-FPM has been restarted." | |
| } >> /var/log/php_fpm_error.log 2>&1 | |
| # else | |
| # { | |
| # echo -e "PHP-FPM is running. $(date +"%F %T")\n" | |
| # } >> /var/log/php_fpm_error.log 2>&1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment