Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-16-2006, 08:30 AM   #1
LQ Newbie
Registered: May 2005
Location: India
Posts: 13

Rep: Reputation: 1
kill process in a single command


I want to kill a running process from a single command line.

Is it possible.

For example :

I am running tomcat
i want to stop the tomcat
But because of some reason the tomcat doesn't stop

so every time when i stop the tomcat i need to grep the tomcat process to check if tomcat is running or not.

And if it is running then need to take the process id and then kill the tomcat process.

I want do the above activity in a single command line.


Old 09-16-2006, 09:16 AM   #2
Senior Member
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
I guess that if you know the name of the process you can do
# killall <name>
Watch out for doing this in *BSD, though. ;P
Old 09-16-2006, 09:30 AM   #3
LQ Newbie
Registered: May 2005
Location: India
Posts: 13

Original Poster
Rep: Reputation: 1
if i grep tomcat i am getting the following.

[root@oracle database]# ps -ef | grep "tomcat"
root 17937 1 0 Jul27 ? 00:00:03 /usr/java/jdk1.5.0_06/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/usr/local/tomcat/conf/ -Djava.endorsed.dirs=/usr/local/tomcat/common/endorsed -classpath :/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/commons-logging-api.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat org.apache.catalina.startup.Bootstrap start
root 16311 16237 0 19:10 pts/1 00:00:00 grep tomcat

In the above case what i need to give the process name.

Old 09-16-2006, 09:35 AM   #4
LQ Newbie
Registered: May 2005
Location: India
Posts: 13

Original Poster
Rep: Reputation: 1
Hi Guys,

thanks for help.

Found out the way to do it.

ps xu | grep tomcat | grep -v grep | awk '{ print $2 }' | xargs kill -9

ps xu | grep <process name> | grep -v grep | awk '{ print $2 }' | xargs kill -9

Hope it will help to all to the member in this forum.

Old 09-16-2006, 11:06 AM   #5
Registered: May 2004
Location: Tampa, Fl
Distribution: Arch
Posts: 648

Rep: Reputation: 30
or, to make it more simple.. run....

killall tomcat


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot kill process (kill -9 does not work) mazer13a Linux - General 1 05-27-2005 03:32 PM
can't kill the process ust Linux - Software 1 09-15-2004 07:05 AM
How can I see what process are running and how to I kill them? (command line). brynjarh Linux - Newbie 4 07-07-2004 04:01 PM
one-line kill command using process name julianop Linux - Newbie 6 12-23-2003 12:33 AM
Kill a process by command ITJedi Programming 3 03-07-2003 11:49 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:24 PM.

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