How to kill Apache Tomcat process in Linux

Sometimes when I develop web app my apache tomcat frozen and I have to do kill process.

Here is command what should do everything by itself.

apache-tomcat-7

[wp_ad_camp_1]

kill -9 `ps aux | grep catalina | grep -v color | grep -v grep | awk '{print $2}'`

You can create bash script also.

  1. Open terminal
  2. Create “killtomcat” file in /usr/bin
    sudo nano /usr/bin/killtomcat
  3. Paste these lines to the file
    #!/bin/bash
    pid=`ps aux | grep catalina | grep -v color | grep -v grep | awk '{print $2}'`
    if [ -n "$pid" ]; then
        echo "Killing process ID: $pid"
        kill -9 $pid
        echo "Done"
    else
        echo "TOMCAT is not running"
    fi
  4. Save the file and close nano
    press keys “CTRL+X”, and answer “Y”, press “Enter”
  5. Set “/usr/bin/killtomcat” as runnable
    sudo chmod a+x /usr/bin/killtomcat
  6. Done. You can now kill Tomacet ever when you want by command
    killtomcat

[wp_ad_camp_1]

Leave a Reply

Your email address will not be published. Required fields are marked *