Created
February 19, 2019 02:44
-
-
Save TsaiKoga/3cb6d99b07b895a50f51358f2c48472a to your computer and use it in GitHub Desktop.
Start / Stop / Restart php-fpm easily
This file contains 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 | |
param=$1 | |
start() { | |
fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk '{print $2}'` | |
if [ ! -n "$fpms" ]; then | |
php-fpm | |
echo "PHP-FPM Start" | |
else | |
echo "PHP-FPM Already Start" | |
fi | |
} | |
stop() { | |
fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk '{print $2}'` | |
echo $fpms | xargs kill -9 | |
for pid in $fpms; do | |
if echo $pid | egrep -q '^[0-9]+$'; then | |
echo "PHP-FPM Pid $pid Kill" | |
else | |
echo "$pid IS Not A PHP-FPM Pid" | |
fi | |
done | |
} | |
case $param in | |
'start') | |
start;; | |
'stop') | |
stop;; | |
'restart') | |
stop | |
start;; | |
*) | |
echo "Usage: ./phpfpm.sh start|stop|restart";; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment