Restart Tomcat regularly in Linux (modify)

Source: Internet
Author: User

1. Write a shell script test. SH and restart tomcat.

#! /Bin/sh </P> <p>. /etc/profile </P> <p> pid = 'ps aux | grep Tomcat | grep-V grep | grep-V retomcat | awk '{print $2} ''< br/> echo $ PID </P> <p> If [-n "$ PID"] <br/> then <br/>{< br/> echo = ========= shutdown ==========================< br/>/opt/tomcat/bin/shutdown. sh <br/> sleep 1 <br/> pid = 'ps aux | grep Tomcat | grep-V grep | grep-V retomcat | awk '{print $2} ''< br/> If [-n "$ PID"] <br/> then <br/>{< br/> sleep 1 <br/> echo ====== = kill Tomcat =================< br/> kill-9 $ PID <br/>}< br/> fi <br/> sleep 1 <br/> echo =========== startup. sh ==================< br/>/opt/tomcat/bin/startup. sh <br/>}< br/> else <br/> echo =========== startup. sh ==================< br/>/opt/tomcat/bin/startup. sh </P> <p> fi </P> <p>

2. Put the test. Sh file in the root directory.

3. Improve Permissions

Chmod A + X test. Sh

4. Enter the following command on the console:
Crontab-e
5. Press the I key to edit the text file, enter the following content, and restart Tomcat at every day.
30 04 ***/root/test. Sh

Press ESC to exit editing, enter WQ, and press enter to save.

6. Start the scheduled service.

[Root @] # service crond stop

[Root @] # service crond start

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.