Operating System - Tru64 Unix
1748169 Members
4008 Online
108758 Solutions
New Discussion юеВ

Kill old processes

 
SOLVED
Go to solution
RJA
Advisor

Kill old processes

I have a number of process that I need to kill. They all have a common string in the process name (the keyword "check" in this case). Is there a way to do this without a separate kill command for each process? I am not familiar with Tru64. Thanks.
3 REPLIES 3
Victor Semaska_3
Esteemed Contributor
Solution

Re: Kill old processes

RJA,

This should work:

ps -eo pid,cmd | grep check | grep -v grep | awk '{print $1}' | xargs kill

But proceed with caution, in other words, use at your own risk. Any other processes with 'check' in it will be terminated as well.

Vic
There are 10 kinds of people, one that understands binary and one that doesn't.
Ivan Ferreira
Honored Contributor

Re: Kill old processes

It would be good if you post a sample ps output, to avoid posting commands that may kill process that you don't want to kill.

A sample command could be like this:

kill `ps auxw |grep check |awk '{print $2}'`

You can create an alias in your .profile, for example:

alias killcheck="kill `ps auxw |grep check |awk '{print $2}'`"

Then all you have to do is to run the killcheck command.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
RJA
Advisor

Re: Kill old processes

thanks !