#!/bin/bash
echo "=========删除jenkins的构建记录===================="
echo "是否删除jenkins的构件记录"
read removeJenkinsBuild
case "$removeJenkinsBuild" in
yes|y|YES|Y)
#删除jenkins的build开始
cd /data/mtl/jenkins/jobs/
localPwd=pwd
echo "当前目录$localPwd"
for file in ./*
do
if [ -d "$file" ]
then
cd $file
echo "删除的目录$file"
rm -rf builds modules
cd -
fi
done
echo "删除build完成"
esac
echo "=========删除docker的log===================="
echo "是否删除docker的日志"
read clearDockerLog
case "$clearDockerLog" in
yes|y|Y|YES)
#删除log
logs=$(find /var/lib/docker/containers/ -name *-json.log)
for log in $logs
do
echo "删除log日志地址 : $log"
cat /dev/null > $log
done
esac
echo "=========删除docker的空镜像(images)===================="
echo "是否删除空的none镜像"
read deleteNone
case "$deleteNone" in
yes|y|YES|Y)
#查询none的镜像
noneImages=$(docker images | grep "none" | awk '{print $3}')
for tempImage in $noneImages
do
echo "删除的当前镜像:$tempImage"
docker rmi $tempImage
done
esac
echo "执行完成..................end"
shell脚本删除docker日志、jenkins的build日志和空的none镜像
最新推荐文章于 2024-08-27 09:17:37 发布