我们公司由于是基于spring cloud开发的java项目,所以所有项目启动都是基于jar包形式的微服务启动的,下面的server_pwd.txt是配置的java启动参数
#!/bin/bash ## java env PATH_WEBAPPS=/opt/platform/ export JAVA_HOME=/opt/platform/tools/jdk1.8.0_111 export JRE_HOME=$JAVA_HOME/jre export JAR_NAME=`grep "$1" ${PATH_WEBAPPS}/server_pwd.txt|awk '{print $NF}'` LOG_NAME=`grep "$1" ${PATH_WEBAPPS}/server_pwd.txt|awk '{print $NF}' |grep -o "[^/]*$" |awk -F "-" '{print $3}' |cut -d"." -f1` DIRECTORY=`grep "$1" ${PATH_WEBAPPS}/server_pwd.txt|awk '{print $NF}' |cut -d"/" -f4` PATH_PWD=$(cd `dirname $0`;echo `pwd`) PATH_TO_JAR=${PATH_WEBAPPS}/$DIRECTORY/${JAR_NAME} PATH_LOG=/data/pdms_data/$LOG_NAME COMMAND_SS=`find /usr -type f -name "ss" | sed -n "1p" | tr -d " "` #PID_PATH_NAME=/var/run/${JAR_NAME}.pid #检查日志 service_check(){ if [ -L ${PATH_LOG}/${JAR_NAME}.log ];then rm -f ${PATH_LOG}/${JAR_NAME}.log && echo "${PATH_LOG}/${JAR_NAME}.log has been deleted." return 0; fi } #检查服务状态 service_status(){ while read line do ps -ef | grep -e "${line}" | grep -v grep >/dev/null 2>&1 if [ $? -ne 0 ];then echo -e "