Skip to content

Instantly share code, notes, and snippets.

@progress44
Created August 4, 2019 22:55
Show Gist options
  • Save progress44/af560de6acd51124c837bb82002babae to your computer and use it in GitHub Desktop.
Save progress44/af560de6acd51124c837bb82002babae to your computer and use it in GitHub Desktop.
Cleaning docker logs if it's not configured correctly
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3",
"labels": "production_status",
"env": "os,customer"
}
}
#!/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