cancel
Showing results for 
Search instead for 
Did you mean: 

killing processes

 
NDO
Super Advisor

killing processes

Hi

 

I have a bunch of processes, that I have to kill them, :

report 22523     1  0  Oct  4  ?         0:00 sh -c /home/report/aceitala/aceitala_load.ksh
  report 22526 22523  0  Oct  4  ?         0:00 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report 29079 29057  0  Oct  2  ?        28:09 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report 24838 24836  0  Oct 10  ?        28:38 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report 23313 23258  0  Oct 17  ?        28:16 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report  5875  5872  0  Oct  8  ?         0:00 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report 26097     1  0  Oct  5  ?         0:00 sh -c /home/report/aceitala/aceitala_load.ksh
  report  5235     1  0  Oct 20  ?         0:00 sh -c /home/report/aceitala/aceitala_load.ksh
  report  2879  2878  0  Oct 24  ?         0:00 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report  4770     1  0  Oct  6  ?         0:00 sh -c /home/report/aceitala/aceitala_load.ksh
  report  6240     1  0  Sep 28  ?         0:00 sh -c /home/report/aceitala/aceitala_load.ksh
  report  2881  2879  0  Oct 24  ?        27:49 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report 13433 13429  0  Oct 13  ?        28:52 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report  5238  5235  0  Oct 20  ?         0:00 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report  3072     1  0  Oct 12  ?         0:00 sh -c /home/report/aceitala/aceitala_load.ksh
  report  5872     1  0  Oct  8  ?         0:00 sh -c /home/report/aceitala/aceitala_load.ksh
  report  5926  5875  0  Oct  8  ?        28:24 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report  5264  5238  0  Oct 20  ?        27:53 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report 22764 22761  0  Oct 15  ?         0:00 /usr/bin/ksh /home/report/aceitala/aceitala_load.ksh
  report 25189     1  0  Oct 22  ?         0:00 sh -c /home/report/aceitala/aceitala_load.ksh

How can I kill them all once, instead of one by one?

all of them have a name in common, but PID is different.

7 REPLIES 7
Steven Schweda
Honored Contributor

Re: killing processes

> How can I kill them all once, instead of one by one?

   Do you mean at exactly the same time, or using one command to do them
all, or what?

   Use a "kill" command with a list of the PID values?

      man kill

   How did you produce that report, some kind of "ps" command?  Are you
really asking how to extract the PID values from the "ps" output?

   Possibly interesting:

$ echo '  report  5872     1  0 ' | sed -e 's/ *[^ ]* *\([^ ]*\) .*/\1/'
5872
MKJ-HPE
HPE Pro

Re: killing processes

all of them have a name in common, but PID is different.

How did you get the list of processes ? 

>How can I kill them all once, instead of one by one?

You can get PID of procsses from "ps -ef" command and then use a script to kill the PIDs.

Please check following discussion links on similar query :

https://community.hpe.com/t5/System-Administration/how-to-kill-all-the-process/td-p/4574416#.XVzrJiMzY2w

https://community.hpe.com/t5/Languages-and-Scripting/how-to-kill-all-process-by-a-script/td-p/4661960#.XVzriCMzY2w

Regards,

 


Accept or Kudo
NDO
Super Advisor

Re: killing processes

Hi

 

I just want to use one command to kill them all.

What I have done so far is to use the kill command plus the PID like:

kill 11458 4385 5245 21619 23436

but there are so many of them

NDO
Super Advisor

Re: killing processes

Hi

I have listed the processes using the following command:

ps -ef | grep aceitala | more

I wonder if this command will work:

ps -ef | grep report | awk '{print $10;}' | grep aceitala |xargs kill

 

 

 

ranganath ramachandra
Esteemed Contributor

Re: killing processes


You might find it easier to use 'ps' in the 'UNIX Standard' mode:

 

I have listed the processes using the following command:

 

ps -ef | grep aceitala | more

(can't quote code block?)

... like:

[ host ~ ] $ ps -aef | grep cimprovagt
    root  2046  2035  0  Jan  7  ?         1:02 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXSASIndicationProviderModule
    root  2045  2035  0  Jan  7  ?         0:21 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXSASNativeIndicationProviderModule
    root  2044  2035  0  Jan  7  ?         1:02 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXRAIDSAIndicationProviderModule
    root  2043  2035  0  Jan  7  ?         0:21 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXRAIDSANativeIndicationProviderModule
    root  2042  2035  0  Jan  7  ?         0:06 /opt/wbem/lbin/cimprovagt 0 4 9 root EMSHAProviderModule
    root  2037  2035  0  Jan  7  ?        259:51 /opt/wbem/lbin/cimprovagt 0 4 9 root SFMProviderModule
    root  2041  2035  0  Jan  7  ?        19:23 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXLANIndicationProviderModule
    root  2047  2035  0  Jan  7  ?         1:23 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXFCIndicationProviderModule
    root  2104  2035  0  Jan  7  ?         1:05 /opt/wbem/lbin/cimprovagt 0 4 8 root HPUXLANProviderModule
    root  2052  2035  0  Jan  7  ?         0:06 /opt/wbem/lbin/cimprovagt 0 4 9 root SGProvidersModule
    root  2051  2035  0  Jan  7  ?         1:16 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXStorageNativeProviderModule
    root  2050  2035  0  Jan  7  ?        11:40 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXStorageIndicationProviderModule
    root  2049  2035  0  Jan  7  ?        3070:24 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXIOTreeIndicationProviderModule
    root  2048  2035  0  Jan  7  ?         0:22 /opt/wbem/lbin/cimprovagt 0 4 9 root HPUXFCNativeIndicationProviderModule
    user 16346 15263  0 14:28:37 pts/0     0:00 grep cimprovagt
[ host ~ ] $ env UNIX95=1 ps -C cimprovagt -o pid
  PID
 2046
 2045
 2044
 2043
 2042
 2037
 2041
 2047
 2104
 2052
 2051
 2050
 2049
 2048

 

I wonder if this command will work:

 

ps -ef | grep report | awk '{print $10;}' | grep aceitala |xargs kill

could be a little more precise with:

[ host ~ ] $ env UNIX95=1 ps -C cimprovagt -o pid | grep -v PID | xargs kill
kill: 2046: permission denied
kill: 2045: permission denied
kill: 2044: permission denied
kill: 2043: permission denied
kill: 2042: permission denied
kill: 2037: permission denied
kill: 2041: permission denied
kill: 2047: permission denied
kill: 2104: permission denied
kill: 2052: permission denied
kill: 2051: permission denied
kill: 2050: permission denied
kill: 2049: permission denied
kill: 2048: permission denied

 


 

 
--
ranga
(i work for hpe)

Accept or Kudo

NDO
Super Advisor

Re: killing processes

Your command will list all the processes owned by user cimprovagt, but I just to want to delete a partcular processes of user report not all of them, that is why I use the 

ps -ef | grep aceitala | more

because I want to kill alll processes that involve "aceitala" string from user report. 

ranganath ramachandra
Esteemed Contributor

Re: killing processes


@NDO wrote:

Your command will list all the processes owned by user cimprovagt


no

 
--
ranga
(i work for hpe)

Accept or Kudo