diff --git a/templates/common/bin/runlogwatch.sh b/templates/common/bin/runlogwatch.sh index 7555eaf5..e69999f2 100755 --- a/templates/common/bin/runlogwatch.sh +++ b/templates/common/bin/runlogwatch.sh @@ -3,15 +3,9 @@ # Ramdisk logs path LOG_DIR=${LOG_DIR:-/var/lib/ironic/ramdisk-logs} -while :; do - sleep 5 - - while read -r fn; do - echo - echo "************ Contents of $fn ramdisk log file bundle **************" - tar -xOzvvf "$fn" | sed -e "s/^/$(basename "$fn"): /" - rm -f "$fn" - # find all *.tar.gz files which are older than six seconds - done < <(find "${LOG_DIR}" -mmin +0.1 -type f -name "*.tar.gz") - -done +inotifywait -m "${LOG_DIR}" -e close_write | + while read -r path _action file; do + echo "************ Contents of ${path}${file} ramdisk log file bundle **************" + tar -xOzvvf "${path}${file}" | sed -e "s/^/${file}: /" + rm -f "${path}/${file}" + done