Skip to content

Instantly share code, notes, and snippets.

@goodjack
Created March 22, 2018 07:52
Show Gist options
  • Select an option

  • Save goodjack/39d62fd105c1ebc69b651ca258d3f471 to your computer and use it in GitHub Desktop.

Select an option

Save goodjack/39d62fd105c1ebc69b651ca258d3f471 to your computer and use it in GitHub Desktop.
Check PhpBrew PHP-FPM, auto restart PHP-FPM if it is down.
#!/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