Created
August 4, 2019 22:55
-
-
Save progress44/af560de6acd51124c837bb82002babae to your computer and use it in GitHub Desktop.
Cleaning docker logs if it's not configured correctly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"log-driver": "json-file", | |
"log-opts": { | |
"max-size": "10m", | |
"max-file": "3", | |
"labels": "production_status", | |
"env": "os,customer" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIR=/var/lib/docker/containers | |
FILES=$(ls $DIR) | |
for f in $FILES | |
do | |
echo "Processing $f dir..." | |
# take action on each file. $f store current file name | |
ls -lash $DIR/$f | grep .log | |
LOGS=$(ls $DIR/$f/ | grep .log) | |
for l in $LOGS | |
do | |
echo "emptying $l logfille" | |
echo "" > $DIR/$f/$l | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment