docker: hourly prune of objects older than 7 days, root mail only when the prune fails

This commit is contained in:
2026-10-26 10:18:29 +00:00
parent d61403ee33
commit fee8ec1ff6
2 changed files with 38 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
# Silent on success: cron mails all output to root, so mail arrives only when the prune fails.
set -u
output=$(docker system prune -af --filter "until=168h" 2>&1)
rc=$?
if [ "$rc" -ne 0 ]; then
printf '%s\n' "$output"
echo "docker system prune exited with rc=$rc"
exit "$rc"
fi