Automatically detects shell scripts of the Tomcat Service

Source: Internet
Author: User

#! /Bin/bash
Pnum_server = 'ps-WEF | grep Tomcat | grep-V grep | WC-l'
If test $ pnum_server-LT 1
Then
/Usr/local/tomcat/bin/shutdown. Sh
Sleep 2 S
/Usr/local/tomcat/bin/startup. Sh
Fi

There must be spaces between square brackets and expressions.

Put the above script named restarttomcat. Sh in crontab and set an interval so that the Tomcat service can detect and automatically restart even if it stops calling it.

The following is a detection every five minutes:

*/5 * su-root-C/root/restarttomcat. Sh

Do not place scripts in the Tomcat directory. Otherwise, the number of processes is incorrect.

If it weren't for my leadership to remind me that I was releasing the script on TomcatProgramAs a result, the execution fails and the execution is depressing. Here THX takes a moment.

 

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.