shell命令执行jar包
#!/bin/bash
# 后台运行jar包,并将日志写到nohup.out文件
APP_NAME=mms.jar
QUERY_LIMIT_TIME=14
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -9 $tpid
fi
# 再次查看进程是否已结束
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -9 $tpid
else
echo 'Stop Procecss Successfully!'
echo 'start Procecss...'
# 启动程序,简单的启动
nohup java -jar $APP_NAME $QUERY_LIMIT_TIME > nohup.out &
# 启动程序,并用jconsole或jvisual监控程序
# nohup java -Djava.rmi.server.hostname=192.168.199.130 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -jar $APP_NAME > nohup.out &
# 动态查看日志文件
tail -300f nohup.out
fi