Tech Support Forum banner
1 - 1 of 1 Posts

·
Registered
Joined
·
1 Posts
Discussion Starter · #1 ·
Hello!

I have this script which works without the while loop and sleeps

but when trying to whole loop it (infinite) the bash comes up with unexpected end (on the last line).

can anyone help me infinite loop this?


Code:
while true
 for i in "${SERVICES[@]}"
 do
    #"not"#
     if [[  "$(service $i status)" =~ "not"  ]]
    then
    service $i start
    MESSAGE= "$(tail -5 /var/log/$i/error.log)"
    SUBJECT="$i Has gone down on $(hostname) $(date) Please fix me!"
    echo "$MESSAGE" | telegram_send
    sleep 900 #stop executing script for 15 minutes
     fi
done
 
1 - 1 of 1 Posts
Top