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