linux shell启动jar包
最近在linux下写shell 调用jar包的程序,刚开始写,虽然代码很少 但是挺齐全感觉还不错。
#!/bin/sh
#description: ngse_sm_server
tpid=`ps aux | grep -c 'ngse_sm.jar'`
case "$1" in
start)
if [ $tpid -le 1 ]; then
echo "NGSE_SM service start..."
sudo "$JAVA_HOME"/bin/java -Xms1024m -Xmx2048m -jar $NGSE_SM/ngse_sm.jar >> $NGSE_SM/log/server.log 2>&1 &
echo $! > $NGSE_SM/server.pid
else
echo "NGSE_SM service already started.PID: `cat $NGSE_SM/server.pid`"
exit 0
fi
;;
stop)
echo "NGSE_SM service stop..."
sudo kill -9 `cat $NGSE_SM/server.pid`
rm -rf $NGSE_SM/server.pid
;;
restart)
echo "NGSE_SM service restart..."
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: ngse_sm_server.sh(start|stop|restart)"
esac
exit 0