编写Linux脚本

 
编写Linux脚本
2016-09-26 19:38:26 /故事大全

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

所属专题:
如果您觉得本文或图片不错,请把它分享给您的朋友吧!

 
故事大全
 
版权所有- © 2012-2015 · 故事大全 SITEMAP站点地图-Foton Auman手机看故事 站点地图-Foton Auman