#!/usr/bin/env bash
jd=`ps -ef | grep xxx | grep -v grep | awk -F" " '{print $2}'`
dt=`date "+%Y-%m-%d %H:%M:%S"`
arr=($jd)
len=${#arr[@]}
if [ "$len" -lt 4 ]
then
echo "xxx process's num less than 4, kill it all (time: $dt)" >> xxx.logs
sh stop.sh
jd=""
sleep 10s
fi
if [ "$jd" = "" ]
then
echo "xxx exe is restarting (time: $dt)" >> xxx.logs
source ~/.bash_profile
sh start.sh
fi