docker日志清理

docker日志如果在没有做滚动的情况下,会越来越多,日志多了,看日志没那么方便,所以有清理的必要,下面是清理的的脚本:

#!/bin/sh
echo "==================== start clean docker containers logs =========================="
 
logs=$(find /var/lib/docker/containers/ -name *-json.log)
 
for log in $logs
        do
                echo "clean logs : $log"
                cat /dev/null > $log
        done
 
 
echo "==================== end clean docker containers logs   =========================="

参考:
https://blog.csdn.net/xunzhaoyao/article/details/72959917

标签: none

添加新评论