LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-17-2005, 05:19 AM   #1
rabeea
Member
 
Registered: Aug 2004
Location: Pakistan
Posts: 52

Rep: Reputation: 15
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
 
Old 03-17-2005, 05:23 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,708

Rep: Reputation: 1829Reputation: 1829Reputation: 1829Reputation: 1829Reputation: 1829Reputation: 1829Reputation: 1829Reputation: 1829Reputation: 1829Reputation: 1829Reputation: 1829
Code:
killall <process name>
 
Old 03-17-2005, 05:25 AM   #3
linuxxed
Member
 
Registered: Feb 2004
Posts: 273

Rep: Reputation: 30
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 {} \;
 
Old 03-17-2005, 05:30 AM   #4
saeed
LQ Newbie
 
Registered: Jun 2003
Location: KSA
Distribution: Red Hat
Posts: 15

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

the command is:-

pkill "process name"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Killing a process fails. Have tried all I know. Racy Linux - Software 6 09-18-2005 12:57 PM
Process killing script owix Linux - General 2 07-19-2005 11:08 AM
Problems killing process Artik Debian 6 05-03-2005 10:29 AM
Killing child process coolfrog Programming 3 09-28-2004 02:58 PM
Really Killing a Process! lazlow69 Linux - Newbie 14 05-10-2003 10:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration