LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Killing a process by its name (https://www.linuxquestions.org/questions/linux-networking-3/killing-a-process-by-its-name-302667/)

rabeea 03-17-2005 05:19 AM

Killing a process by its name
 
HI All,

Can we kill any process by its name in Linux???
I tried to find that but got no clue so i tried the following command to get those processes

ps -aux |grep java > java

now i got all the process with name java in it but now i dont know how to get that particular strings of PID out of it and kill it.

Actually I want to cron the script of killing the process after everyone hour. By it should be by name.

regards
Rabeea

bathory 03-17-2005 05:23 AM

Code:

killall <process name>

linuxxed 03-17-2005 05:25 AM

Re: Killing a process by its name
 
Quote:

Originally posted by rabeea
HI All,

Can we kill any process by its name in Linux???
I tried to find that but got no clue so i tried the following command to get those processes

ps -aux |grep java > java

now i got all the process with name java in it but now i dont know how to get that particular strings of PID out of it and kill it.

Actually I want to cron the script of killing the process after everyone hour. By it should be by name.

regards
Rabeea

you can write yur customised kill script to kill by name if you want. In the meanwhile this one liner shoulddo the job.

ps -ef|grep java| awk '{print $2}' | xargs kill {} \;

saeed 03-17-2005 05:30 AM

you can even use alternative command if you wanna to kill a process by its name.

the command is:-

pkill "process name"


All times are GMT -5. The time now is 06:37 AM.