kafka 分区迁移统计时间脚本

时间:2022-12-12 12:24:26
#!/bin/bsah

starttime=`date +'%Y-%m-%d %H:%M:%S'`;
echo "Start: $starttime";

/app/ctgkafka/ctg_kafka_instance/13/icc-5gcmp-kafka-yl5/1/bin/kafka-reassign-partitions.sh --zookeeper 172.25.1.136:2181,172.25.1.53:2181,172.25.1.144:2181/ctgkafka/13/icc-5gcmp-kafka-yl5 --reassignment-json-file topic-reassignment.json --execute --throttle 10240000

x=1

while true;
do

if [ $x -gt 0 ];
then
echo "1" >>/dev/null

elif [ $x -eq 0 ]
then
date >>/opt/date.txt
break
fi


x=`/app/ctgkafka/ctg_kafka_instance/13/icc-5gcmp-kafka-yl5/1/bin/kafka-reassign-partitions.sh --zookeeper 172.25.1.136:2181,172.25.1.53:2181,172.25.1.144:2181/ctgkafka/13/icc-5gcmp-kafka-yl5 --reassignment-json-file topic-reassignment.json --verify | grep "progress" |wc -l`

done

endtime=`date +'%Y-%m-%d %H:%M:%S'`;
echo "End: $endtime";
echo "End: $endtime" >> /opt/date.txt
start_seconds=$(date --date="$starttime" +%s);
end_seconds=$(date --date="$endtime" +%s);
echo "本次运行时间: "$((end_seconds-start_seconds))"s"


 

nohup  sh date.sh > date.sh.log  2>&1 &