下面是重新启动Linux下某进程的shell脚本。以tomcat进程为例:

#!/bin/sh
pid=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`
if [ "$pid" = "" ] ; then
    echo "tomcat service does not start!"
else
    kill -9 $pid
    pid1=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`
    if [ "$pid1" = "" ] ; then
        echo "Successfully kill tomcat processes: " $pid
    else
        echo "tomcat kill process failed!"
        exit 1
    fi
fi
rm -rf /opt/tomcat/work/*
./startup.sh
pid2=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`
if [ "$pid2" = "" ] ; then
   echo "tomcat service failed to start!"
else
   echo "tomcat service starts successfully:" $pid2
fi

相关文章:

  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-04-22
猜你喜欢
  • 2021-05-09
  • 2021-06-13
  • 2021-05-08
  • 2021-11-03
  • 2021-10-13
  • 2021-12-25
  • 2021-12-23
相关资源
相似解决方案