Skip to content

Instantly share code, notes, and snippets.

@progress44
Created August 8, 2019 13:02
Show Gist options
  • Save progress44/f37b0716a6676d5978001ac734bc3706 to your computer and use it in GitHub Desktop.
Save progress44/f37b0716a6676d5978001ac734bc3706 to your computer and use it in GitHub Desktop.
Clean docker logs if docker is misconfigured
#!/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