Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to kill a process in Ubuntu.

I have Java installed and Running JBOSS & Tomcat at background. I need to kill Tomcat after deployment but when I kill it JBOSS is going too.

I had to use

kill -9 pidofjava
killall tomcat

But status is still same.

What I need to do to kill a process attribute? I mean subprocess?

share|improve this question

2 Answers 2

Usually processes check whether their subprocesses are still alive and might shut down themselves if one of the subprocesses is aborted.

share|improve this answer

You can loop through the process list, identifying children with the same parent and kill them one by one.

Attribution: http://www.unix.com/17901-post4.html

#!/bin/sh
while true
do
  echo "Enter parent process id  [type quit for exit]"
  read ppid

  if [ $ppid -eq "quit" -o $ppid -eq "QUIT" ];then
     exit 0
  fi

  for i in `ps -ef| awk '$3 == '$ppid' { print $2 }'`
  do
      echo killing $i
      kill $i
  done
done

You can also kill by session id but that get's the parent and the children.

http://serverfault.com/questions/40303/how-do-you-kill-a-process-tree-in-linux

ps -eo pid,ppid,sess,cmd -u ppetraki | grep whoami

pkill -9 -s SESS_ID

Using the information from the later, you could build a simpler tool that targeted only children.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.