在Linux中执行任务脚本

在Linux中执行任务脚本,第1张

在Linux中执行任务脚本
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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5704470.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存