cronjob: adding volume prune in system prune cronjob

This commit is contained in:
Marco Procaccini 2026-02-04 13:02:01 +01:00
parent cc8ad6786f
commit 2a432eb639
1 changed files with 13 additions and 5 deletions

View File

@ -1,9 +1,17 @@
#!/usr/bin/env bash
LOG_FILE="/var/log/docker-system-prune.log"
echo "===== $(date '+%Y-%m-%d %H:%M:%S') =====" >> "$LOG_FILE"
# "system" prune, because pruning images only leaves a lot of garbage around
docker system prune -a --force >> "$LOG_FILE" 2>&1
echo "" >> "$LOG_FILE"
VOL_LOG_FILE="/var/log/docker-volume-prune.log"
echo "===== $(date '+%Y-%m-%d %H:%M:%S') =====" >> "$VOL_LOG_FILE"
# "volume" prune, because pruning volumes only leaves a lot of garbage around
docker volume prune --force >> "$VOL_LOG_FILE" 2>&1
echo "" >> "$VOL_LOG_FILE"
SYS_LOG_FILE="/var/log/docker-system-prune.log"
echo "===== $(date '+%Y-%m-%d %H:%M:%S') =====" >> "$SYS_LOG_FILE"
# "system" prune, because pruning images only leaves a lot of garbage around
docker system prune -a --force >> "$SYS_LOG_FILE" 2>&1
echo "" >> "$SYS_LOG_FILE"
exit 0