I have a challenge shutting down effectively php-fpm
; not all processes stop running and as such, php-fpm
does not restart as expected.
I want a command line to run that will kill all the php-fpm
process so I can add it to init.d
so a stop will ensure they are all removed.
Below is the result of ps -aux | grep php-fpm
;
793 102971 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool tokyodating.co
794 102972 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool turkeydating.co
794 102973 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool turkeydating.co
794 102974 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool turkeydating.co
795 102975 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool ukrainedating.co
795 102976 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool ukrainedating.co
795 102977 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool ukrainedating.co
796 102978 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool unemployeddating.com
796 102979 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool unemployeddating.com
796 102980 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool unemployeddating.com
822 102981 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool datingcougar.co
822 102982 0.0 0.1 4520304 5868 ? S 13:20 0:00 php-fpm: pool datingcougar.co
822 102983 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool datingcougar.co
798 102984 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vegandating.co
798 102985 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vegandating.co
798 102986 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vegandating.co
799 102987 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vegetariandating.co
799 102988 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vegetariandating.co
799 102989 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vegetariandating.co
800 102990 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vietnamdating.co
800 102991 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vietnamdating.co
800 102992 0.0 0.1 4520304 5888 ? S 13:20 0:00 php-fpm: pool vietnamdating.co
720 103001 0.0 0.2 4522680 10672 ? S 13:21 0:00 php-fpm: pool kuwaitdating.co
746 103008 0.1 0.2 4522684 10132 ? S 13:23 0:00 php-fpm: pool newzealanddating.co
746 103009 0.0 0.1 4520304 5876 ? S 13:23 0:00 php-fpm: pool newzealanddating.co
How can I kill all php-fpm
processes running a single command line?
If you started it in background use ps aux | grep time. php to get PID. Then just kill PID . If process started in foreground, use to interrupt it.
PHP-FPM is a service which executes PHP code on behalf of a web server. As NGINX is unable to natively execute PHP code, it can be onfigured to pass all . php files over to PHP-FPM.
Depending on your setup this could be managed via fast-cgi or mod_php or even php-fpm. If you use mod_php , then there will be no "php processes" visible for ps . You can still see if your PHP engine is in use by using lsof : $ lsof -ln [...]
The best way is to close the terminal window as we cannot type anything while the server is running! Press the (X) button on the top right(on Windows/Linux)/Press the red color circle on the top left(on Mac OS) of the terminal window to stop the PHP server from running.
You can use killall instead, it takes a process name instead of a PID
killall -KILL php-fpm
ps: -9
and -KILL
are the same
if who get problem like me:
-bash: killall: command not found
you can use:
sudo kill -9 `sudo ps -ef | grep php-fpm | grep -v grep | awk '{print $2}'`
I found this command here: https://gist.github.com/bmichalski/c8d25fff041a4739d6f0126edb0e9b54 , it worked for me.
If you are having issues where killall
is not a command on your environment, I would recommend the following:
To kill all php-fpm for your user
pkill php-fpm
To kill all php-fpm for all users
sudo pkill php-fpm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With