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