Last active
October 16, 2022 21:14
-
-
Save yazanmonshed/4355270e6df96a0811090c3272de6baf to your computer and use it in GitHub Desktop.
Remove Docker Containers 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
#!/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