Linux PS-EF exclude current process (kill current Tomcat process)

Source: Internet
Author: User

In Linux, we often use "ps-ef|grep tomcat" to view the process as the result of using the command on the server I am working on:



As you can see, there is a process for that command in addition to the 3 purple Tomcat.

If you want to exclude the current process of the red box, you can add a parameter filter after the original command, as follows:

Ps-ef|grep tomcat|grep-v grep


Only so, because I personally have a need: Write a sh script in the Tomcat/bin directory, kill the current Tomcat process.

Write the kill.sh script and place the script in the Tomcat/bin directory with the following contents:

#!/bin/shtom_home=$ (CD ' DirName $ '; CD.; PWD) kill-9 ' ps-ef|grep $TOM _home|grep-v Grep|awk ' {print $} '


Use the command chmod +x kill.sh to grant executable permissions to the script.







Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux PS-EF exclude current process (kill current Tomcat process)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.