From 36d62a99d32fc5eb9bdc7e64a398865772367180 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Sun, 9 Nov 2025 12:44:46 +0100 Subject: [PATCH] core: improve log cleaning --- misc/core.func | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/misc/core.func b/misc/core.func index ca454d02a..3254761eb 100644 --- a/misc/core.func +++ b/misc/core.func @@ -369,7 +369,9 @@ run_container_safe() { } cleanup_lxc() { + # Minimal, robust cleanup after install/update – no toggles, always runs. msg_info "Cleaning up" + if is_alpine; then $STD apk cache clean || true rm -rf /var/cache/apk/* @@ -379,13 +381,15 @@ cleanup_lxc() { $STD apt -y clean || true fi - rm -rf /tmp/* /var/tmp/* - - # Remove temp files created by mktemp/tempfile + # Clear temp artifacts (keep sockets/FIFOs; ignore errors) find /tmp /var/tmp -type f -name 'tmp*' -delete 2>/dev/null || true find /tmp /var/tmp -type f -name 'tempfile*' -delete 2>/dev/null || true - find /var/log -type f -exec truncate -s 0 {} + + # Truncate writable log files silently (permission errors ignored) + if command -v truncate >/dev/null 2>&1; then + find /var/log -type f -writable -print0 2>/dev/null | \ + xargs -0 -n1 truncate -s 0 2>/dev/null || true + fi # Python pip if command -v pip &>/dev/null; then pip cache purge || true; fi @@ -407,8 +411,8 @@ cleanup_lxc() { if command -v composer &>/dev/null; then composer clear-cache || true; fi if command -v journalctl &>/dev/null; then - $STD journalctl --rotate - $STD journalctl --vacuum-time=10m + $STD journalctl --rotate || true + $STD journalctl --vacuum-time=10m || true fi msg_ok "Cleaned" }