Skip to content

Instantly share code, notes, and snippets.

@ivuorinen
Last active May 7, 2025 08:38
Show Gist options
  • Save ivuorinen/f6c02c8f5cad7186827e77837ad0ef90 to your computer and use it in GitHub Desktop.
Save ivuorinen/f6c02c8f5cad7186827e77837ad0ef90 to your computer and use it in GitHub Desktop.
Find and truncate Traefik log
#!/usr/bin/env bash
# Truncate Traefik high volume log
# CRONTAB: 0 */2 * * * /root/scripts/traefik-truncate-log.sh > /dev/null 2>&1
TRAEFIK=$(docker ps --no-trunc | grep 'traefik' | awk '{ print $1 }');
TRAEFIK_PATH="/var/lib/docker/containers/$TRAEFIK/";
/usr/bin/find "$TRAEFIK_PATH" -type f \( -name "*-json.log" \) -size +5M -exec bash -c 'echo "" > "$1"' _ {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment