#!/bin/bash
type=$1
if [ "$type" = "" ]
then
echo "请输入参数 start|stop|status"
exit 8
fi
pid=`ps -ef|grep xxx.jar|grep -v "grep"|awk '{print $2}'`
LOGDIR=/root/xxx/log
JVM_OPTS="-Xms512m -Xmx512m -Xmn256m"
HEAP_DUMP_OPTS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$LOGDIR"
JAVA_OPTS="$JVM_OPTS $HEAP_DUMP_OPTS"
case $type in
"status")
echo "查看状态"
if [ "$pid" = "" ]
then
echo "Stopping!!!"
else
echo "Running!!!"
fi
;;
"start")
if [ "$pid" = "" ]
then
nohup java $JAVA_OPTS -jar xxx.jar > $LOGDIR/output 2>&1 &
echo "Start finished!!!"
else
kill -9 $pid
nohup java $JAVA_OPTS -jar xxx.jar > $LOGDIR/output 2>&1 &
echo "Start finished!!!"
fi
;;
"stop")
echo "停止程序"
if [ "$pid" = "" ]
then
echo "Stopping finished!!!"
else
kill -9 $pid
echo "Stopping finished!!!"
fi
;;
esac
java jar包在linux上运行的脚本
最新推荐文章于 2024-04-03 12:03:19 发布