2004-12-21, 10:07 PM
Code:
ps -efj |grep user |awk '{print $2}'|xargs kill -9
cheers
anyweb and thanks grepster
:)
how to kill a user
|
2004-12-21, 10:07 PM
Code: ps -efj |grep user |awk '{print $2}'|xargs kill -9 cheers anyweb and thanks grepster :)
2005-03-21, 09:24 PM
Quote: i would like to point out dangers in using this. one if you have two users with names that are close (eg user user1) and you attempt to kill all 'user's procs... user1's will go too. two if the command line has 'user' in it (eg 'sshd: user [priv]' normally a root proc) that will go too (or for the fact user turns up anywhere else in the line). this one-liner is just a little too eager. a command called pkill can solve this though: Code: pkill -u uid done (you can do Code: pkill -u user as well)
2005-03-21, 09:28 PM
nice follow up thanks can you provide a working example ? cheers anyweb
2005-03-21, 09:49 PM
Sure.... Code: pkill -u znx Will kill all processes started by user 'znx'. Code: pkill -u 1982 Will kill all processes started by the user with the UID of 1982. Actually just as a side note. If you have a daemon started by say root and that daemon starts processes under a different user then you can find processes starting back up immediately after the pkill (e.g. apache)
2009-06-12, 02:44 PM
Firstly, this should be "how to STOP PROCESSES", rather than users. Secondly, to retrieve a user's processes, use: Code: ps -fu USERNAME Since then only processes owned by that user will be returned, rather than processes that match the username somewhere in the line (the user1/user10 problem) Thirdly, I'd not do a "kill -9". Try to do an ordinary kill (-15) first to allow the process to quit gracefully. "-9" will leave all kinds of rubbish left behind (open DB connections, temporary files, orphaned processes, persistent filelocks, etc). |
« Next Oldest | Next Newest »
|