Skip to content

Docker logs files eats the free space, clearing the Docker logs files is required. #2

Description

@smartblu9

Docker logs files eats the free space, clearing the Docker logs files is necessary.

Here is a way .

  1. run nano /home/maximo/void-logs-containers.sh and write this content in it :
    #!/bin/bash
    for container in $(docker ps -q); do
    echo "Clearing logs for $container"
    sudo echo "" > $(docker inspect --format="{{.LogPath}}" $container)
    done

(save : ctrl+O, close : ctrl+X, make it executable : chmod +x)

  1. Run it manually : sudo /home/maximo/void-logs-containers.sh

  2. Plan its automatic execution (root) :
    sudo bash
    crontab -e
    (select nano, choice 1)
    (add some lines for running it at desired hours)
    0 06 * * * /home/maximo/void-logs-containers.sh >> /home/maximo/void-logs-containers.log 2>&1
    0 14 * * * /home/maximo/void-logs-containers.sh >> /home/maximo/void-logs-containers.log 2>&1
    0 22 * * * /home/maximo/void-logs-containers.sh >> /home/maximo/void-logs-containers.log 2>&1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions