How to Stop or Kill a Process Running on Your Linux Server?

How to Kill a Process in Linux?

To find out the processes running on your server :

ps aux

This will show you the 'PID' of the process along with it's other information. You can delete a process by using the 'kill' command with the process PID

kill 16516

Sometimes you run into errors that require emergent steps like killing of certain process. For example, if you have certain PHP processes running in the background which are stuck and taking up valuable server resources, you can kill the PHP processes only on the server instead of restarting the whole server.

To list all the processes of a certain name :

ps aux | grep 'process_name'

For example if you wish to display all the PHP processes :

ps aux | grep 'php'

You can further improve this command,

ps aux | grep '[p]hp'

To kill all the processes of a given name, for example all MYSQL processes :

kill $(ps aux | grep '[m]ysql' | awk '{print $2}')

Just replace the mysql with the process name you wish to kill all processes of and also don't forget to add the first character in '[ ]' brackets.

WPOven
© 2024 WPOven Inc. All rights reserved. WPOven® and WordPress® are registered trademarks.
WPOven is the best Managed WordPress hosting for agencies and businesses that want to succeed. With Unlimited sites hosting option, its easy to use and manage, so you can focus on growing your business. 
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram