Archive

Posts Tagged ‘kill user processes linux’

How to Kill a List of Processes at Once in Linux

April 28th, 2010 No comments

Sometimes we need to kill a bunch of processes. For example, we have run a plenty of PHP scripts from command line, and have noticed there are errors in them. Let’s say the wrong script is called php_script.php. Then in order to terminate all processes associated with script name, you need to issue the following command:

kill `ps aux | grep php_script.php | grep -v grep | awk '{print $2}'`

What does this command actually do? It sends process IDs found by ps to the kill command. Then all these processes are killed. This command is used when any other methods, like killall -9 php are not acceptable for any reason.

Delete all Processes of a Single User Linux

July 5th, 2008 No comments

Sometimes server load is caused by a single user, that runs lots of stuff. In order to prevent server overload you should detect most heavy processes by using ps. Then you may need to know what processes are run by this user. This will be done using ps -u <username>. If you think that al user processes should be terminated, issue the following command: pkill -u username. This will kill only processes started by the specified user.

Here is a flash demo of this command, I think you can find it useful.