Linux OS uses crontab for timed shutdown to start tomcat

Source: Internet
Author: User
In the Linux operating system, use crontab to regularly shut down and start the tomcat linux operating system. to create a scheduled task, follow these steps:

After you connect to the system using an ssh tool, perform the following steps:

1) crontab-l view timing;

2) crontab-e indicates that the scheduled task can be edited, but the editing mode is not enabled yet;

3) enter I again to enter the editing mode;

4) copy the self-written timing code as follows:

0 4 ***/opt/ltim/tomcat/bin/shutdown. sh --- indicates that tomcat is disabled at 4 o'clock every day;

20 4 ***/opt/ltim/tomcat/bin/startup. sh --- indicates that tomcat is enabled at 04:10 every day;

5) press and hold the esc key to exit the editing mode;

6) save and exit and enter ": wq !";

During the scheduled task today, the following occurs: you can manually restart tomcat to execute the task, but you cannot execute it in the crontab scheduled task. the solution is to configure java_home in the. sh file.

Export JRE_HOME =/opt/ltim/j2sdk

In addition, the shell script for restarting tomcat is attached:

#! /Bin/sh

#./Etc/profile

Export JRE_HOME =/opt/ltim/j2sdk

Sh/opt/ltim/tomcat/bin/shutdown. sh

Sleep 30 s

Sh/opt/ltim/tomcat/bin/startup. sh

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.