Skip to content

Instantly share code, notes, and snippets.

@yazanmonshed
Last active October 16, 2022 21:14
Show Gist options
  • Save yazanmonshed/4355270e6df96a0811090c3272de6baf to your computer and use it in GitHub Desktop.
Save yazanmonshed/4355270e6df96a0811090c3272de6baf to your computer and use it in GitHub Desktop.
Remove Docker Containers Logs
#!/bin/bash
# dir logs files
PATHLOGS=/var/lib/docker/containers/
## This script is only for remove logs for docker containers
## Please make sure to change permission for file such chmod +x remove-docker-logs.sh
# Vlidate path for docker logs
if [ ! -d $PATHLOGS ]; then
echo "the $PATHLOGS is not found!"
exit 1
else
truncate -s 0 $PATHLOGS/*/*-json.log
fi
# Check if the logs deleted secessfully
if [ $? -eq 0 ]; then
echo "Delete logs compelete secessfully"
else
echo "Delete logs is failed!"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment