主脚本ansible.sh:
sum=`ansible all -i inventory_new -f 100 -m script -a "script.sh" -u support | grep logSize | grep -v stdout |sed 's/"//g' |awk '{sum += $3};END {print sum}'`
GB=`echo "scale=2; $sum/1048576" | bc`
echo "总更新大小为: ${GB} G"
script使用脚本script.sh:
for i in `find /home/*/app/ -newermt '2019-12-20 00:00:00' -newermt '2019-12-20 21:00:00' |xargs -I{} du -sk {} | awk '{print $1}'` ;
do b=$((b+i));
done ;
echo "logSize is" $b
前提需求:
1.inventory_new 为你的ansible_host文件
2.ansible.sh和inventory_new 和script.sh 在同一个目录下









网友评论