KILLING ALL USER PROCESSES
The common method for killing all of a users processes
usually involves grepping the users name from ‘ps’, then
using awk to get the process id’s and submitting them
to ‘kill -9′.
Sys V
ex: kill -9 $(ps -fuusername | awk ‘{ print $2 }’ )
BSDish
ex: kill -9 $(ps -aux |grep username | awk ‘{ print $2 }’ )
The problems with doing this way are that it is slow, and
more importantly, it doesn’t always kill all of the processes
on the first try.
There is a way to do this that always kills all of the users
processes the first time, and is very fast:
su – username -c ‘kill -9 -1′
Note:
The -c Option
Among the most commonly used of su’s few options is -c, which tells su to execute the command that directly follows it on the same line. Such command is executed as the new user, and then the terminal window or console from which su was run immediately returns to the account of the former user after the command has completed execution or after any program that it has launched has been closed.
- Unix tips at UGU
No comments yet
Jump to comment form | comments rss [?] | trackback uri [?]