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