最新室内设计效果图,南阳网站推广优化公司哪家好,做网站工资多少钱,企业官网建站联系我们一、前言
平常工作中#xff0c;我们的开发的项目部署到linux环境#xff0c;以jar包的方式运行#xff0c;涉及jar包的启动、停止、查看状态等#xff0c;我们可以通过脚本的方式进行维护#xff0c;减少自己敲打一长串的命令少敲一个字母或者多敲一个字母#xff0c;方…一、前言
平常工作中我们的开发的项目部署到linux环境以jar包的方式运行涉及jar包的启动、停止、查看状态等我们可以通过脚本的方式进行维护减少自己敲打一长串的命令少敲一个字母或者多敲一个字母方便维护。 二、脚本
vim app.sh
#!/bin/bashappNamexxxx.jar
if [ -z $appName ]
thenecho Please check that this script and your jar-package is in the same directory!exit 1
fikillForceFlag$2function start()
{countps -ef |grep java|grep $appName|wc -lif [ $count ! 0 ];thenecho Maybe $appName is running, please check it...elseecho The $appName is starting...nohup java -jar $appName --spring.profiles.activetest log.out 21 fi
}function stop()
{appIdps -ef |grep java|grep $appName|awk {print $2}if [ -z $appId ]thenecho Maybe $appName not running, please check it...elseecho -n The $appName is stopping...if [ $killForceFlag -f ]thenecho by forcekill -9 $appIdelseechokill $appIdfifi
}function status()
{appIdps -ef |grep java|grep $appName|awk {print $2}if [ -z $appId ]thenecho -e \033[31m Not running \033[0melseecho -e \033[32m Running [$appId] \033[0mfi
}function restart()
{stopfor i in {3..1}doecho -n $i sleep 1doneecho 0start
}function help()
{echo Usage: $0 {start|stop|restart|status|stop -f}echo Example: $0 startexit 1
}function taillog()
{tail -f -n 1000 log.out
}case $1 instart)start;;stop)stop;;restart)restart;;status)status;;taillog)taillog;;*)help;;
esac
三、授权及命令
chmod x app.sh
启动app.sh start
停止app.sh stop -f
查看状态 app.sh status