Java suspended animation, but the process is still in, you can determine whether the log file changes over time to determine whether Java suspended animation
The shell script is as follows:
#!/bin/bash# #通过比较五分钟前后, log file MD5 value is the same, to determine whether the log file changes, so as to determine whether Java suspended animation # Please according to the actual situation, modify environment variables, Project path # Join the scheduled task execution #function Restartjava () {export java_home=/opt/apps/jdk1.6.0_41export path= $PATH:/opt/apps/jdk1.6.0 _41/binexport classpath=.: $JAVA _home/lib/tools.jar: $JAVA _home/lib/dt.jar: $JAVA _home/jre/lib/ Rt.jarjavapath= "/opt/apps/apache-tomcat-6.0.37" javaid=$ (ps -ef|grep java |grep $ javapath |grep -v "grep" |awk ' {print $2} ') kill -9 $JAVAIDCD $ javapath/bin && /bin/bash startup.sh} #while [ 1 ] #doFirst = ' md5sum / opt/shell/nohup.out |awk ' {print $1} ' sleep 300second= ' Md5sum /opt/shell/nohup.out |awk ' {print $1} ' if [[ $First == $Second ]]then echo "Start restart java" >/dec/null 2>&1 &nbSp; restartjavafi#done
This article is from the "future Time and Space" blog, please be sure to keep this source http://sjitwant.blog.51cto.com/3661219/1734238
Shell determines if the file has changed