doker 使用脚本清理容器日志
编辑sh脚本,
vim /var/lib/docker/containers/cleanLogs.sh
输入以下内容:
echo "======== docker containers logs file size ========" logs=$(find ./ -name *-json.log) for log in $logs do ls -lh $log done echo "======== start clean docker containers logs ========" logs=$(find ./ -name *-json.log) for log in $logs do echo "clean logs : $log" cat /dev/null > $log done echo "======== end clean docker containers logs ========"
保存之后修改文件权限
chmod 777 cleanLogs.sh
执行脚本
/. cleanLogs.sh