#!/bin/sh
my_ip=`/sbin/ifconfig eth1 | grep 'inet addr' | awk '{print substr($2, index($2, ":")+1)}'`
recv=""
msg="not_existing, restart ..."
MONITOR_LOG="monitor.log"
#monitor procname scriptname
monitor()
{
# 查找进程
pgrep ^$1$ > /dev/null
# 如果不存在, 就重启他.
if [ $? -ne 0 ] ; then
echo "`date` ${my_ip}.$1 $msg";
$2 restart
fi
sleep 2
}
echo "`date` monitor begin ..." >> ../log/monitor.log
monitor "server" "/home/rti/rti/scripts/Server.sh" >> ${MONITOR_LOG}
monitor "connector" "/home/rti/rti/scripts/Connector.sh" >> ${MONITOR_LOG}
echo "`date` monitor end ..." >> ../log/monitor.log
进程监控脚本
最新推荐文章于 2023-04-17 00:16:32 发布