[SunHELP] kill
Graeme Mathieson
sunhelp at sunhelp.org
Thu Jun 21 02:57:54 CDT 2001
On Wed, Jun 20, 2001 at 04:03:23PM -0700, Naresh wrote:
>
> > I am trying to kill all processes that belong to a user but my command
> > fail, checkout my command and see what is wrong.
> > # ps -e | grep foo | grep -v grep | awk '{print $1}' xargs kill -9
>
> This works for me:
> ps -ef|grep USER|grep -v grep|awk '{print $2}'|xargs kill -9
As a slight optimisation:
ps -ef|grep [U]SER|awk '{print $2}'|xargs kill -9
for example:
ps -ef|grep [g]raeme|awk '{print $2}'|xargs kill -9
This way, the command line for grep doesn't match the regular
expression, so there's no need to lose grep from the resulting output.
Anyway, with your version, you wouldn't have killed all that user's grep
processes. ;)
--
graeme+sig at mathie.cx http://www.mathie.cx/~graeme/
More information about the SunHELP
mailing list