编写脚本文件快速实现java服务的启动和停止
startup.sh
sh#!/bin/sh
current_dir=$(cd `dirname $0`;pwd)
nohup java -Dloader.path=.,3rd-lib,resources -Dfastjson.parser.safeMode=true -Xmx1g -Xms1g -jar ${current_dir}/xxxx.jar >/dev/null 2>&1 &
if [ $? -eq 0 ]
then
echo $! > server.pid
echo "start Success!"
else
echo "start Faild!"
exit;
fi
shutdown.sh
sh#!/bin/sh
pid="./server.pid"
if [ -f "$pid" ]; then
kill -9 `cat $pid`
rm -rf $pid
echo "Stop Server Success!"
else
echo "pid file not found;"
fi

在jar文件路径下执行
./startup.sh ./shutdown.sh


本文作者:千寻
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!