不灭的焱

革命尚未成功,同志仍须努力

作者:php-note.com  发布于:2021-08-05 15:51  分类:Java框架/系统  编辑

1.启动命令

jar名称:

prs_count=jps -l |grep "uc-auth-1.0.0" | wc -l

文件路径:

/home/jdk1.8/jdk1.8.0_131/jre/bin/java -jar /home/uc/uc-auth-1.0.0.jar

使用指定环境挂到后台运行:

--spring.profiles.active=dev &

startup.sh

#!/usr/bin/env bash

prs_count=0

prs_count=`jps -l |grep "uc-auth-1.0.0" | wc -l`

if [ ${prs_count} -lt 1 ] ; then
	echo -e "Startup uc-auth..."
    sleep 10
	/home/jdk1.8/jdk1.8.0_131/jre/bin/java -jar /home/har-uc/uc-auth-1.0.0.jar --spring.profiles.active=dev &
else
	echo -e "uc-auth is running..."
fi
exit 0

2.关闭命令

shutdown.sh

#!/usr/bin/env bash

prs_count=0

prs_count=`jps -l |grep "uc-auth-1.0.0.jar" | wc -l`

if [ ${prs_count} -lt 1 ] ; then
	echo -e "uc-auth is not running..."
else
	echo -e "Shutdown uc-auth"
    sleep 10
	kill -9 `jps -l|grep "uc-auth-1.0.0.jar" |awk '{print $1}'`
fi
exit 0

 

参考:https://blog.csdn.net/weixin_43687353/article/details/109741782

 

 

【工作中的一次调整】

start.sh

#!/usr/bin/env bash
 
jar_name='wm_aaa_service-1.0.0.jar'

prs_count=`jps -l | grep ${jar_name} | wc -l`
 
if [ ${prs_count} -lt 1 ] ; then
    echo -e "启动jar包中..."
    sleep 10
    java -jar ${jar_name} --spring.profiles.active=dev  2>&1 >> debug.log 2>&1 /dev/null &
else
    echo -e "jar包已启动..."
fi
exit 0

stop.sh

#!/usr/bin/env bash
 
jar_name='wm_aaa_service-1.0.0.jar'
 
prs_count=`jps -l | grep ${jar_name} | wc -l`
 
if [ ${prs_count} -lt 1 ] ; then
    echo -e "jar包未启动..."
else
    echo -e "正在jar包..."
    sleep 10
    kill -9 `jps -l | grep ${jar_name} | awk '{print $1}'`
fi
exit 0

 

 

其他参考:gocron系统启动脚本  run.sh start|stop|restart

#!/bin/sh

case $1 in
	start)
        sleep 5
		nohup ./gocron 2>&1 >> info.log 2>&1 /dev/null &
		echo "服务已启动..."
	;;
	stop)
        sleep 5
		killall gocron
		echo "服务已停止..."
	;;
	restart)
		sleep 5
        killall gocron
		sleep 5
		nohup ./gocron 2>&1 >> info.log 2>&1 /dev/null &
		echo "服务已重启..."
	;;
	*)
		echo "$0 {start|stop|restart}"
		exit 4
	;;
esac