#!/bin/sh set -e MACHINE_ID=$(cat /etc/machine-id) CURRENT_LOGS=/var/log/journal/${MACHINE_ID} # Cleanup if [ ! -d ${CURRENT_LOGS} ]; then rm -rf /var/log/journal/* exit 0 fi # Loop all logs folder and move for log_folder in /var/log/journal/*; do # Not a log folder if [ ! -d ${log_folder} ]; then continue fi # Current log folder if (echo ${log_folder} | grep ${MACHINE_ID}); then continue fi mv ${log_folder}/* ${CURRENT_LOGS}/ rm -rf ${log_folder} done journalctl --vacuum-size=20M