1. Write a shell script test.sh, restart Tomcat
[Java]View Plaincopy
- #!/bin/sh
- . /etc/profile
- Pid= ' ps aux | grep Tomcat | Grep-v grep | Grep-v Retomcat | awk ' {print $} '
- Echo $pid
- If [-N "$pid"]
- Then
- {
- Echo ===========shutdown================
- /opt/tomcat/bin/shutdown.sh
- Sleep 1
- Pid= ' ps aux | grep Tomcat | Grep-v grep | Grep-v Retomcat | awk ' {print $} '
- if [-N "$pid"]
- Then
- {
- Sleep 1
- Echo ========kill tomcat==============
- Kill-9 $pid
- }
- Fi
- Sleep 1
- Echo ===========startup.sh==============
- /opt/tomcat/bin/startup.sh
- }
- Else
- Echo ===========startup.sh==============
- /opt/tomcat/bin/startup.sh
- 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