LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

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

Rep: Reputation: 1
kill process in a single command


Hi,

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.


Thanx

Anand
 
Old 09-16-2006, 08:16 AM   #2
Ephracis
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
Code:
# killall <name>
Watch out for doing this in *BSD, though. ;P
 
Old 09-16-2006, 08:30 AM   #3
vbseeker
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/logging.properties -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 -Djava.io.tmpdir=/usr/local/tomcat/temp 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.

Regards,
Anand
 
Old 09-16-2006, 08:35 AM   #4
vbseeker
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.

Regards,
Anand
 
Old 09-16-2006, 10:06 AM   #5
DeusExLinux
Member
 
Registered: May 2004
Location: Tampa, Fl
Distribution: Arch
Posts: 648

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

killall tomcat
 
  


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 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 02:32 PM
can't kill the process ust Linux - Software 1 09-15-2004 06: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 03:01 PM
one-line kill command using process name julianop Linux - Newbie 6 12-22-2003 11:33 PM
Kill a process by command ITJedi Programming 3 03-07-2003 10:49 AM


All times are GMT -5. The time now is 11:54 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration