#!/bin/bash
function check(){
count=`ps -ef |grep $1 |grep -v "grep" |wc -l`
time=`date '+%Y-%m-%d %H:%M:%S'`
if [ 0 == $count ];then
echo "$time $1 is not running,start $1"
/etc/init.d/$1 start
else
echo "$time $1 is running"
fi
}
check mysqld
check php-fpm-54
写到定时任务里,每分钟检测一次