Skip to content

Instantly share code, notes, and snippets.

@sparkida
Created August 25, 2017 12:54
Show Gist options
  • Save sparkida/62e72df4331ebd3fcc0c31a5ff571689 to your computer and use it in GitHub Desktop.
Save sparkida/62e72df4331ebd3fcc0c31a5ff571689 to your computer and use it in GitHub Desktop.
Truncate/Flush docker logs
#!/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
@sparkida
Copy link
Author

sparkida commented Aug 27, 2017

sudo truncate -s 0 $(docker inspect node | grep log | awk '{print $2}' | cut -d\" -f2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment