系统:centos 5.x
脚本内容:
cat kingate.sh
代码如下 | 复制代码 |
#!/bin/bash kingate=`ps -C kingate --no-header|wc -l` file=`find /usr/local/kingate/var/kingate.pid |wc -l` if [ "$kingate" = "1" ];then echo "kingate is running...." else if [ "$file" = "1" ];then rm -f /usr/local/kingate/var/kingate.pid /etc/init.d/kingate start sleep 1 kingate=`ps -C kingate --no-header|wc -l` if [ "$kingate" = "1" ];then echo "kingate is ok!" else /etc/init.d/kingate start fi fi fi |
用crontab每隔3分钟执行下kingate.sh这个脚本,当然如果你不嫌浪费资源的话,还可以自己搞个邮件报警.
原文来自:blog.slogra.com
时间: 2024-09-20 05:38:21