-
-
Save sparkida/62e72df4331ebd3fcc0c31a5ff571689 to your computer and use it in GitHub Desktop.
Truncate/Flush docker logs
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
#!/usr/bin/env bash | |
containerName=''; | |
truncateDockerLog(){ | |
truncate -s 0 $(docker inspect $containerName | grep log | awk '{print $2}' | cut -d\" -f2) | |
} | |
# pass no args and truncate all | |
# pass a container name and truncate that container | |
if [ "x$1" = 'x' ]; then | |
$(docker ps -aq) | while read containerName; do | |
truncateDockerLog | |
done | |
else | |
containerName="$1" | |
truncateDockerLog | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo truncate -s 0 $(docker inspect node | grep log | awk '{print $2}' | cut -d\" -f2)