Skip to content

Instantly share code, notes, and snippets.

@innateessence
Last active September 1, 2024 23:41
Show Gist options
  • Select an option

  • Save innateessence/ab022646a49286b2bfd80a7f8dd50585 to your computer and use it in GitHub Desktop.

Select an option

Save innateessence/ab022646a49286b2bfd80a7f8dd50585 to your computer and use it in GitHub Desktop.

Revisions

  1. innateessence revised this gist Sep 1, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clean-docker-logs.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # But sometimes, a script that solves the problem is better.
    # This CAN cause issues if this runs while docker is appending logs to the file.
    # It is possibly that if you use this, `docker logs` will throw an error due to a partial log entry being present and unparsable by docker.
    # Don't use this if you don't understand what I just said.
    # Don't use this if you don't understand what I just said in the line above.

    LOG_PATH="$HOME/Library/Containers/com.docker.docker/Data/log/host"

  2. innateessence revised this gist Sep 1, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clean-docker-logs.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # But sometimes, a script that solves the problem is better.
    # This CAN cause issues if this runs while docker is appending logs to the file.
    # It is possibly that if you use this, `docker logs` will throw an error due to a partial log entry being present and unparsable by docker.
    # Don't use this if you don't know what you're doing.
    # Don't use this if you don't understand what I just said.

    LOG_PATH="$HOME/Library/Containers/com.docker.docker/Data/log/host"

  3. innateessence revised this gist Sep 1, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clean-docker-logs.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # I am aware this can be handled via configuration instead.
    # But sometimes, a script that solves the problem is better.
    # This CAN cause issues if this runs while docker is appending logs to the file.
    # It is possibly that if you use this, `docker logs` will throw an error due to a partial log entry being present.
    # It is possibly that if you use this, `docker logs` will throw an error due to a partial log entry being present and unparsable by docker.
    # Don't use this if you don't know what you're doing.

    LOG_PATH="$HOME/Library/Containers/com.docker.docker/Data/log/host"
  4. innateessence revised this gist Sep 1, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clean-docker-logs.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/env bash

    # I am aware this can be handled via configuration instead.
    # But sometimes, a script that solves the problem better.
    # But sometimes, a script that solves the problem is better.
    # This CAN cause issues if this runs while docker is appending logs to the file.
    # It is possibly that if you use this, `docker logs` will throw an error due to a partial log entry being present.
    # Don't use this if you don't know what you're doing.
  5. innateessence revised this gist Aug 22, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clean-docker-logs.sh
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    # It is possibly that if you use this, `docker logs` will throw an error due to a partial log entry being present.
    # Don't use this if you don't know what you're doing.

    LOG_PATH='/Users/jack/Library/Containers/com.docker.docker/Data/log/host'
    LOG_PATH="$HOME/Library/Containers/com.docker.docker/Data/log/host"

    function wipe_log(){
    # $1: log file path
  6. innateessence revised this gist Aug 22, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clean-docker-logs.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ LOG_PATH='/Users/jack/Library/Containers/com.docker.docker/Data/log/host'
    function wipe_log(){
    # $1: log file path
    # example usage:
    # wipe_log "$LOG_PATH/monitor.log.0" true
    # wipe_log "$LOG_PATH/monitor.log.0"
    local log_file="$1"

    truncate -s 0 "$log_file"
  7. innateessence revised this gist Aug 7, 2024. 1 changed file with 1 addition and 6 deletions.
    7 changes: 1 addition & 6 deletions clean-docker-logs.sh
    Original file line number Diff line number Diff line change
    @@ -6,25 +6,20 @@
    # It is possibly that if you use this, `docker logs` will throw an error due to a partial log entry being present.
    # Don't use this if you don't know what you're doing.

    VERBOSE=true
    LOG_PATH='/Users/jack/Library/Containers/com.docker.docker/Data/log/host'

    function wipe_log(){
    # $1: log file path
    # example usage:
    # wipe_log "$LOG_PATH/monitor.log.0" true
    local log_file="$1"
    local verbose="{2:-false}"
    if [ "$verbose" = true ]; then
    echo "Wiping log file: $log_file"
    fi

    truncate -s 0 "$log_file"
    }

    function Main(){
    for log_file in "$LOG_PATH"/* ; do
    wipe_log "$log_file" "$VERBOSE"
    wipe_log "$log_file"
    done

    du -sh "$LOG_PATH"
  8. innateessence created this gist Aug 7, 2024.
    33 changes: 33 additions & 0 deletions clean-docker-logs.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/usr/bin/env bash

    # I am aware this can be handled via configuration instead.
    # But sometimes, a script that solves the problem better.
    # This CAN cause issues if this runs while docker is appending logs to the file.
    # It is possibly that if you use this, `docker logs` will throw an error due to a partial log entry being present.
    # Don't use this if you don't know what you're doing.

    VERBOSE=true
    LOG_PATH='/Users/jack/Library/Containers/com.docker.docker/Data/log/host'

    function wipe_log(){
    # $1: log file path
    # example usage:
    # wipe_log "$LOG_PATH/monitor.log.0" true
    local log_file="$1"
    local verbose="{2:-false}"
    if [ "$verbose" = true ]; then
    echo "Wiping log file: $log_file"
    fi

    truncate -s 0 "$log_file"
    }

    function Main(){
    for log_file in "$LOG_PATH"/* ; do
    wipe_log "$log_file" "$VERBOSE"
    done

    du -sh "$LOG_PATH"
    }

    Main