linux 启动jar包脚本
run.sh文件:
ps -ef|grep java|grep lccloud-salary-service|awk '{print $2}'|xargs kill -9 nohup java -server -Xms512m -Xmx1024m -Xss256k -jar lccloud-salary-service.jar --spring.profiles.active=bit &
restart.sh文件:
部署流程(以oa-service为例):
1)jar包传到~/app/backend/oa-service/jar
2)重启服务:sh restart.sh oa-service prd
3)查看日志:tail -f app.log
app=$1 env=$2 if [ ! -d "bak" ]; then echo "bak文件夹不存在,创建bak文件夹" mkdir bak else echo "bak文件夹已存在" fi pid=`ps aux | grep ${app}.jar | grep -v grep | awk '{print $2}'` echo "pid = ${pid}" if [ ! -n "$pid" ]; then echo "${app}进程不存在,直接启动服务" else echo "${app}进程存在pid=${pid},先kill再启动服务" kill -9 ${pid} fi echo "备份当前jar: cp ${app}.jar bak/" cp ${app}.jar bak/ echo "替换最新jar: cp jar/${app}.jar ." cp jar/${app}.jar . echo "启动${app}进程: nohup java -server -Xms512m -Xmx1024m -Xss256k -jar ${app}.jar --spring.profiles.active=${env} >> app.log 2>&1 &" nohup java -server -Xms512m -Xmx1024m -Xss256k -jar ${app}.jar --spring.profiles.active=${env} >> app.log 2>&1 &
随笔看心情