通過crontab調度改腳本
#!/usr/bin/env bash
###############################################################
#檢測實時程序是否存在的腳本,若不存在,則重啓
#Param 1 實時程序名稱後半部分
#Param 2 啓動程序腳本名稱
#Param 3 調度週期
###############################################################
#定義重啓方法
function restart(){
count=0
while true
do
num=`yarn application -list |grep tabbit|grep lemon.$1 |wc -l`
if [ "${num}"x = "0"x ];then
count=$[$count + 1]
if [ ${count} == 3 ];then
ctime=`date "+%Y-%m-%d %H:%M:%S"`
echo $ctime "restart......" >> /tmp/realtime_restart_log/$1.log
sh /home/ads/rabbit/bin/realtime/$2.sh $3 &
break
else
sleep 1m
fi
else
count=0
break
fi
done
}
#檢測實時程序
restart StreamingContext real_time_script 60
exit 0