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 |
I guess that if you know the name of the process you can do
Code:
# killall <name> |
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 |
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 |
or, to make it more simple.. run....
killall tomcat |
All times are GMT -5. The time now is 12:15 AM. |