1. clean.sh 清理-json.log文件
#! /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 =========================="
echo `date`
2. crontab 每天定时做清理
crontab -e
0 0 * * * /bin/sh /root/${clean-folder}/clean-log.sh > /root/${clean-folder}/record-log.log
service crond restart
网友评论