Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Last active May 2, 2024 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/89ade457d1362c6039369a458b298f99 to your computer and use it in GitHub Desktop.
Save jrichardsz/89ade457d1362c6039369a458b298f99 to your computer and use it in GitHub Desktop.
docker truncate logs - snippets

/acme/truncate_log.sh

echo "clear container log : $(date)"
df -h
name=$(docker ps --format '{{.Names}}')
log_file=$(docker inspect --format='{{.LogPath}}' $name)
du -h "${log_file}" | cut -f 1
echo "" > $(docker inspect --format='{{.LogPath}}' $name )
du -h "${log_file}" | cut -f 1

rm -rf /var/log/eb-docker/containers/eb-current-app/rotated/*

echo "clear /var/log files"

for f in $(find /var/log/eb-docker/containers/eb-current-app -maxdepth 1 -type f); do
    echo "current file is $f"
    echo "" > "$f"
done

contrab -e

*/5 * * * *  bash /acme/truncate_log.sh >> /var/log/truncate_log.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment