diff --git a/conf/mingan_reboot.sh b/conf/mingan_reboot.sh index d90b026..c01aeac 100644 --- a/conf/mingan_reboot.sh +++ b/conf/mingan_reboot.sh @@ -5,8 +5,17 @@ export LANG="zh_CN.UTF-8" BASE_DIR="/data/jieling/sensitiveWordFilter" LOG_DIR="/data/jieling/sensitiveWordFilter/logs" -pid=`ps -ef|grep java|grep "SensitiveWord"|awk '{print $2}'` -kill $pid -sleep 5 +process_name=SensitiveWord +# 使用ps命令查找进程并将结果保存到变量中 +process_count=`ps -ef|grep java|grep "${process_name}"|awk '{print $2}'` + +# 判断进程数是否大于0,如果大于0,则进程存在;否则,进程不存在 +if [ -z "$process_count" ]; then + echo "进程 $process_name 存在." + kill $process_count + sleep 5 +else + echo "进程 $process_name 不存在." +fi nohup java -Dfile.encoding=UTF-8 -server -Xms1g -Xmx1g -Xss512K -XX:MaxMetaspaceSize=256m -XX:CompressedClassSpaceSize=64m -XX:+UseG1GC -XX:ParallelGCThreads=8 -XX:ConcGCThreads=4 -XX:NativeMemoryTracking=detail -verbose:gc -Xloggc:${LOG_DIR}/gc_core.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:-OmitStackTraceInFastThrow -Djava.ext.dirs=${BASE_DIR}/lib:$JAVA_HOME/jre/lib/ext -cp ${CLASSPATH} com.ljsd.SensitiveWordApplication --spring.config.location=${BASE_DIR}/conf/application.properties >> corelog.log 2>&1 &