Linux timed reboot tomcat (modified)

Source: Internet
Author: User

1. Write a shell script test.sh, restart Tomcat

[Java]View Plaincopy
  1. #!/bin/sh
  2. . /etc/profile
  3. Pid= ' ps aux | grep Tomcat | Grep-v grep | Grep-v Retomcat | awk ' {print $} '
  4. Echo $pid
  5. If [-N "$pid"]
  6. Then
  7. {
  8. Echo ===========shutdown================
  9. /opt/tomcat/bin/shutdown.sh
  10. Sleep 1
  11. Pid= ' ps aux | grep Tomcat | Grep-v grep | Grep-v Retomcat | awk ' {print $} '
  12. if [-N "$pid"]
  13. Then
  14. {
  15. Sleep 1
  16. Echo ========kill tomcat==============
  17. Kill-9 $pid
  18. }
  19. Fi
  20. Sleep 1
  21. Echo ===========startup.sh==============
  22. /opt/tomcat/bin/startup.sh
  23. }
  24. Else
  25. Echo ===========startup.sh==============
  26. /opt/tomcat/bin/startup.sh
  27. Fi

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 this text file, enter the following, restart Tomcat every day 4:30
* * * */root/test.sh

Press the ESC key to exit the edit, enter Wq return to save

6. Start the timer service

[[Email protected]]# service Crond Stop

[[Email protected]]# 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.