wgetでリンク切れを発見してメール送信するシェルスクリプト

#!/bin/sh
MAIL_FROM="mailfrom@yourdomain.com"
MAIL_RECIPIENT="mailto@yourdomain.com"
TMP_FILE=/tmp/check.txt
URL="http://yourdomain.com/"
wget --spider --recursive --no-directories --no-verbose ${URL} 2>&1 | grep -A100 "broken link." | tee ${TMP_FILE}
COUNT=`cat ${TMP_FILE} | wc -l`

if [ "${COUNT}" -ne "0" ]; then
  /usr/sbin/sendmail -t  << EOF
From: ${MAIL_FROM}
To: ${MAIL_RECIPIENT}
Subject: Broken link for ${URL}

`cat ${TMP_FILE}`
EOF
fi