Shell脚本监控程序运行状态,并在必要时终止进程
发布时间
阅读量:
阅读量
Shell脚本监控程序运行情况(结束进程)
在另一篇博客中提到了启动程序,在这里我们探讨如何编写停止程序的脚本。
#! /bin/bash
while true
do
monitoring=` ps -ef|grep Manipulator |grep -v grep| wc -l`
if [ $monitoring -eq 0 ]
then
echo "Manipulator is not running "
else
echo "Manipulator is running, and kill it"
ps -ef| grep Manipulator| grep -v grep| awk '{print $2}'| xargs kill -9 #xargs 将前面的结果作为参数给 kill-9
fi
sleep 3
done
其中指令的具体含义已在上一篇
ps -ef| grep Manipulator| grep -v grep| awk '{print $2}'| xargs kill -9 #xargs 将前面的结果作为参数给 kill-9
从前面一直到 awk ' {pr
全部评论 (0)
还没有任何评论哟~
