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.



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
    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"
        echo "TOMCAT is not running"
  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


Leave a Reply

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