一、建立腳本文件docker
vi cleandocker.sh
內容以下:json
#!/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 =========================="
二、給腳本文件受權spa
chmod 755 cleandocker.sh
三、執行腳本code
./cleandocker.sh