From ac2ee2f48c9a66e2525bcc384a7df5da86140dec Mon Sep 17 00:00:00 2001 From: gitea Date: Fri, 25 Aug 2023 22:04:40 +0800 Subject: [PATCH] [modify] add a condition to determine if the file is empty --- alert/docker_alarm.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/alert/docker_alarm.sh b/alert/docker_alarm.sh index 08c8b5d..16e9f7b 100644 --- a/alert/docker_alarm.sh +++ b/alert/docker_alarm.sh @@ -10,6 +10,8 @@ while read line; do fi done < /opt/logs/docker_status.log -alarm=`cat /tmp/docker_alarm.log` -python3 /opt/scripts/alert/sendmail.py "Docker Alarms" "$alarm" +if [[ -s /tmp/docker_alarm.log ]]; then + alarm=`cat /tmp/docker_alarm.log` + python3 /opt/scripts/alert/sendmail.py "Docker Alarms" "$alarm" +fi