【liunx中jar包启动脚本】#!/bin/sh## Appctrl This shell script takes care of starting and stopping#the VccpDataServer (vccpdsctrl).############ jar包存放的位置prog_path="/usr/local/app/admin"# jar包名称prog_name="admin-1.1.0"exec="JAVA -Xms1024m -Xmx1024m -jar $prog_path""/""$prog_name"".jar"#查看进程号prog_pid=`ps -ef | grep $prog_name | grep -v grep | cut -c 10- | cut -c -5|sed 's/ //g'`prog_time=`date --date='0 days ago' "+%Y/%m/%d %H:%M:%S"`# get_pidget_pid(){prog_pid=`ps -ef | grep $prog_name | grep -v grep | cut -c 10- | cut -c -5|sed 's/ //g'`echo $prog_pid}start(){prog_pid=$(get_pid);if [ -n "$prog_pid" ]; then echo ${prog_time} "$prog_name (pid:$prog_pid) ,and it's running." return 1fiecho ${prog_time} "$prog_name Starting ..."#export JAVA_HOME=/home/javahome#export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar#export PATH=$PATH:$JAVA_HOME/binecho $execnohup $exec >/dev/null 2>&1 &sleep 10prog_pid=$(get_pid);if [ -z "$prog_pid" ]; then echo ${prog_time} "Start $prog_name is failed." return 2fiecho ${prog_time} "$prog_name (pid:$prog_pid) is running."echo ${prog_time} "Start $prog_name is ok."return 0}stop(){echo ${prog_time} "$prog_name Stoping..."prog_pid=$(get_pid);if [ -n "$prog_pid" ]; then echo ${prog_time} "Found $prog_name (pid:$prog_pid)"kill -9 $prog_pidfisleep 3prog_pid=$(get_pid);if [ -n "$prog_pid" ]; thenecho ${prog_time} "Stop $prog_name is failed." return 1fiecho ${prog_time} "Stop $prog_name is ok."return 0}status(){prog_pid=$(get_pid);if [ -n "$prog_pid" ]; then echo ${prog_time} "$prog_name (pid:$prog_pid) is running..." return 0fiecho ${prog_time} "$prog_name is stoped."return 1}restart(){stopstart}# See how we were called.case "$1" instart)start;;stop)stop;;status)status;;restart)restart;;*)echo $"Usage: $0 {start|stop|status|restart}"exit 2esacexit $?
推荐阅读
- 在 Java 中断言内部行为
- go-micro集成链路跟踪的方法和中间件原理
- 计量检测中心校准证书上的CMA、CNAS、CAL有什么意义,区别在哪?
- 饵料|《师傅请赐教》中年男人解压方式竟是夜钓?背后原因让人深思
- 中国最美乡村全集
- 中国最美丽的村庄是什么
- 冲红茶泡中间,润元昌红茶系列
- 骁龙8|中兴Axon 40 Pro官方渲染图首度公布:“双圆环”后摄模组抢眼
- 中国联通|中国联通推出“5G视频号”:打通通信网和互联网 能当彩铃
- 苹果|标准版成丐中丐!iPhone 14系列配置图出炉:低配依然60Hz刘海屏、无缘A16