#!/bin/sh
path=/xxx/xxx
time=$(date "+%Y%m%d")
log_path=$path/logs/nohup.out
jar_name=xxx.jar
#获取程序进程ID
tpid=`ps -ef|grep $jar_name|grep -v grep|grep -v kill|awk '{print $2}'`
#如果存在 关闭程序
if [ ${tpid} ]; then
while [ ${tpid} ]
do
echo 'Stoping...'
kill -9 $tpid
sleep 1
tpid=`ps -ef|grep $jar_name|grep -v grep|grep -v kill|awk '{print $2}'`
if [ !${tpid} ]; then
break;
fi
done
echo 'Stop Procecss Successfully!'
fi
#启动程序
nohup java -jar $path/$jar_name > $log_path 2>&1 &
echo 'Starting...'
tail -f $log_path
java -jar shell启动脚本
于 2022-05-11 11:53:07 首次发布