PID=`ps -ef | grep testDemo | grep -v grep | awk '{print $2}'`
if [[ ${PID} != "" ]];
then
echo "任务-testDemo-SNAPSHOT.jar-线程-${PID}-已经存在"
echo "关闭任务输入[C],重启任务输入[R],继续请按其它:"
read th
if [ ${th} = "C" -o ${th} = "c" ] ;
then
echo "任务-testDemo-SNAPSHOT.jar-即将关闭......"
kill -9 ${PID}
echo "任务-testDemo-SNAPSHOT.jar-关闭成功"
elif [ ${th} = "R" -o ${th} = "r" ] ;
then
echo "任务-testDemo-SNAPSHOT.jar-即将重启......"
kill -9 ${PID}
nohup java -jar testDemo-SNAPSHOT.jar > /dev/null 2>&1 &
# nohup java -jar testDemo-SNAPSHOT.jar &
# rm -f ./nohup.out
echo "任务-testDemo-SNAPSHOT.jar-重启成功"
else
echo "其它-${th}"
fi
else
nohup java -jar testDemo-SNAPSHOT.jar > /dev/null 2>&1 &
# nohup java -jar testDemo-SNAPSHOT.jar &
# rm -f ./nohup.out
fi
在Linux中执行任务脚本
最新推荐文章于 2024-05-17 16:41:20 发布