3w多买的iOS垃圾桶,配置上Jenkins做为打包机,大大提高了团队的打包效率。但是随着项目数量和项目迭代的增加,打包机的磁盘越来越不够用,需要定时给打包机瘦身。
使用shell脚本遍历需要清理的目录,对2周之前的包进行删除。有些包特别大的,也可以设定更短的时间处理。
#!/bin/bash echo "clean before ........" df -h echo ">>>>>>>>>>>>>>>>>>>>>>>cleaning ......" my_array=("a" "b" "c" "d" "e" \ "rld" "_src" "xxx" "ssss" \ "dddya" "an" "ynp") for loop in ${my_array[@]} do echo "-------begin clean project $loop-------" pfile="$HOME/xxx/build_result/ios/$loop" if [[ -d "$pfile" ]] then if [[ "$pfile" =~ "dddya" ]]; then find $pfile -mtime +5 -exec rm -rf {} \; else find $pfile -mtime +15 -exec rm -rf {} \; fi else echo "$loop project not exist" fi echo "------end clean project $loop-------" echo "" echo "" done pfile="$HOME/Downloads/DerivedData" echo "-------begin clean DerivedData-------" find "$pfile" -mtime +0 -exec rm -rf {} \; echo "-------end clean DerivedData----------" pfile="$HOME/Downloads/Archives" echo "-------begin clean Archives-------" find "$pfile" -mtime +5 -exec rm -rf {} \; echo "-------end clean Archives----------" echo ">>>>>>>>>>>>>>>>>>>clean after ........" 复制代码