浏览量:108次
以下是重启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/*
./
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
[声明]本网转载网络媒体稿件是为了传播更多的信息,此类稿件不代表本网观点,本网不承担此类稿件侵权行为的连带责任。故此,如果您发现本网站的内容侵犯了您的版权,请您的相关内容发至此邮箱【779898168@qq.com】,我们在确认后,会立即删除,保证您的版权。