Bulk Kill Java Process Method-elicit child shell and dereference

Source: Internet
Author: User

Method:

Kill–9 ' pgrep Java '

Use the above command to kill all Java processes running on the server at once.

Extension: The role of child shells and anti-application in shell scripts

Let's look at an example of a child shell:

# Cat Text1.txt
1
2
3
4
5
# text01=$ (cat text1.txt)
#echo $text 01
1 2 3) 4 5

As can be seen from the example, a child shell is a part referenced with $ (), and the child shell runs as a separate process and does not have an effect on the parent shell. Child shell output does not preserve line breaks by default.

Take a look at a counter-reference example, in fact, the above kill Java process is the use of the anti-reference implementation, of course, can also be implemented through the child shell.

# echo ' Cat text1.txt '
1 2 3) 4 5

The anti-reference default is also not to preserve line breaks. If you want to keep the newline character, you can use double quotation marks to refer to the Anti-reference section as follows:

# echo "' Cat Text1.txt '"
1
2
3
4
5

The role of child shells and anti-references in Shell scripting is still important.

Bulk Kill Java Process Method-elicit child shell and dereference

Related Article

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.