From 6dde8b7b1ceda0832c9997bc4a62f878f032b1b8 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Wed, 12 Aug 2020 16:19:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1leanup=20log=20files=20after=20image-gene?= =?UTF-8?q?ration=20on=20Ubuntu=20(#1395)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/linux/scripts/installers/cleanup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/images/linux/scripts/installers/cleanup.sh b/images/linux/scripts/installers/cleanup.sh index 954e51fc9..387a22402 100644 --- a/images/linux/scripts/installers/cleanup.sh +++ b/images/linux/scripts/installers/cleanup.sh @@ -8,6 +8,19 @@ before=$(df / -Pm | awk 'NR==2{print $4}') apt-get clean rm -rf /tmp/* +# journalctl +if command -v journalctl; then + journalctl --rotate + journalctl --vacuum-time=1s +fi + +# delete all .gz and rotated file +find /var/log -type f -regex ".*\.gz$" -delete +find /var/log -type f -regex ".*\.[0-9]$" -delete + +# wipe log files +find /var/log/ -type f -exec cp /dev/null {} \; + # after cleanup after=$(df / -Pm | awk 'NR==2{print $4}')