Docker logs files eats the free space, clearing the Docker logs files is necessary.
Here is a way .
- 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)
-
Run it manually : sudo /home/maximo/void-logs-containers.sh
-
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
Docker logs files eats the free space, clearing the Docker logs files is necessary.
Here is a way .
#!/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)
Run it manually : sudo /home/maximo/void-logs-containers.sh
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