From 3100bc2e633cd1c74fea7a89b2d0820d74a7912b Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Fri, 27 Nov 2020 10:19:37 +0300 Subject: [PATCH] add cleanup-logs.sh post-generation script (#2138) --- images/linux/post-generation/cleanup-logs.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 images/linux/post-generation/cleanup-logs.sh diff --git a/images/linux/post-generation/cleanup-logs.sh b/images/linux/post-generation/cleanup-logs.sh new file mode 100644 index 00000000..335f8486 --- /dev/null +++ b/images/linux/post-generation/cleanup-logs.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# 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 {} \; \ No newline at end of file