Url check creating child process and generating false alerts

Hi All

Below code is working as expected but creating too many child processes when the url is not up and every minute that process is sending false email alerts

any help with the logic not to generate child process and not to send duplicate alerts

app="https://url"
appresult=$(wget --no-check-certificate -S $app 2>&1>/dev/null | grep -c "HTTP/1.1 401")
if [ "$appresult" -eq "0" ]; then
  MESSAGE="Application has stopped running on "$HOST
 echo  $MESSAGE | mailx -s  $App_Down_alert $ADMIN
 fi

Please correct me, but I'm seeing a single pass code snippet only, no loop or other reason for multiple connects, child processes, mails. Is that the entire code? Or did you miss something?

URL2="https://url"
sent=`cat url.txt | grep sent | awk -F"=" {'print $2'}`
appresult=$(wget --no-check-certificate -S $URL 2>&1>/dev/null | grep -c "HTTP/1.1 401")
if [ "$appresult" -gt "0" ]; then
  /bin/sh url-reset.sh
elif [ "$appresult" -eq "0" ]; then
  MESSAGE="Application stopped running on "$HOST
if [ "$usent" != "y" ]; then
 echo  $MESSAGE | mailx -s $App_Down_Alert $ADMIN
 sed -i "s/usent=n/usent=y/" url.txt
 else
echo "already sent"
  fi
fi

---------- Post updated at 05:22 PM ---------- Previous update was at 05:22 PM ----------

The above script will check for duplicates emails and will not send using sed in text file