CentOS Stop Tomcat Run script code _linux

Source: Internet
Author: User

Code validation passed, reserved, ready for later use

#!/bin/sh
#
# Firstly find the process of the tomcat ....
Tomcat_process_str= ' ps aux | grep ' Java.*tomcat ' | Grep-v grep '
process_array= (${tomcat_process_str///})
tomcat_process_id=${process_array[1]}
echo $ tomcat_process_id
#
Secondly send stop tomcat to = if we can kill it
Stoptomcat sleep
#
# Last we'll use kill Tomcat process into a looking up loop for
((a=1;a<=10;a++)) do
 Check_str_length=0
  tomcat_process_check_str= ' ps aux | grep ' Java.*tomcat ' | Grep-v grep '
 check_str_length=${#TOMCAT_PROCESS_CHECK_STR}
# Number of parameters passed to the script;
 if [$CHECK _str_length!= 0]
 then
  kill $TOMCAT _process_id
  5
  echo Try to kill TOMCAT once
 ... Else
  Echo Tomcat is already killed
  break
 fi
do
#使用两次grep来去除grep自身进程对于查找结果的干扰是非常有技巧的
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.