您当前的位置: 首页 > 网络技术  > 服务器教程 浏览
编写Linux脚本
发布时间:2015-12-12    点击率:次    来源:www.sytcke.com    作者:电脑技术学习网

   以下是重启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

来源 电脑技术网 www.sytcke.com
发表留言
发表留言请先登录!
免责声明:本站发布的信息和评论纯属网民个人行为,并不代表本站立场,如发现有违法信息或侵权行为,请直接与本站管理员联系,我们将在收到您的信息后24小时内作出处理!