apache-flume重启脚本, apache-flume重启经常性的启动多个进程,杀不干净,就写个重启脚本。
#echo -e 参数输出为红色,网上可以搜下shell输出带颜色的字体编码很多。
cat obi-track_restart.sh #!/bin/bash pid=`lsof -i:8787 | grep java | awk '{print $2}'` if [ -n "${pid}" ];then echo -e "############\033[31m kill ${pid} \033[0m#############" for i in "${pid}" do echo $i kill -9 "${i}" sleep 5 check_pid=`lsof -i:8787 | grep java | awk '{print $2}'` if [ -z "${check_pid}" ];then echo -e "############\033[31m flume已经杀掉,正在启动 \033[0m#############" else kill -9 ${check_pid} fi done nohup /data/apache-flume-1.6.0-bin/bin/flume-ng agent -c /data/apache-flume-1.6.0-bin/conf/ -f /data/env/obi/obi-track/track_conf.properties -n a1 -Dflume.root.logger=INFO,console > /data/apache-flume-1.6.0-bin/flume.log 2>&1 & echo -e "##############\033[31m 启动完成 \033[0m###############" else nohup /data/apache-flume-1.6.0-bin/bin/flume-ng agent -c /data/apache-flume-1.6.0-bin/conf/ -f /data/env/obi/obi-track/track_conf.properties -n a1 -Dflume.root.logger=INFO,console > /data/apache-flume-1.6.0-bin/flume.log 2>&1 & echo -e "##############\033[31m 启动完成 \033[0m###############" fi