From 4353ba4d86894af8c17d18b4a9c280ca08e4c6b4 Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 15 May 2024 09:52:07 +0200 Subject: [PATCH] add additional existence check for ls /tmp/vm* --- cpu.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cpu.sh b/cpu.sh index 1c547d7..96bb48d 100755 --- a/cpu.sh +++ b/cpu.sh @@ -77,10 +77,12 @@ for VM in ${OUT}; do fi done -SEEN=$(ls -1 /tmp/vm* | awk -F'/' '{print $3}') -for s in ${SEEN[@]}; do - if [[ "${OUT[*]}" != *"${s}"* ]]; then - if [ -n "${DEBUG}" ]; then echo "${s} - remove from tracking list"; fi - rm -rf /tmp/${s} - fi -done +if ls /tmp/vm* 1> /dev/null 2>&1; then + SEEN=$(ls -1 /tmp/vm* | awk -F'/' '{print $3}') + for s in ${SEEN[@]}; do + if [[ "${OUT[*]}" != *"${s}"* ]]; then + if [ -n "${DEBUG}" ]; then echo "${s} - remove from tracking list"; fi + rm -rf /tmp/${s} + fi + done +fi