以下是重启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
- 看不过瘾?点击下面链接!
- 修改Linux中的用户名
- Linux在终端启动程序关闭终端不退出的方法
- 机械硬盘和固态硬盘多系统启动“no bootable device”解决方法
- WINPE下不显示硬盘的解决技巧
- XPSP3系统IIS安装过程
- Linux下如何将数据库脚本文件从sh格式变为sql格式