d1=$(date --date="-10 min" "+%Y-%m-%d %H:%M")
d2=$(date --date="-1 min" "+%Y-%m-%d %H:%M")
sed -n "/$d1/,/$d2/p" /tmp/samba.log
while read -r line; do
if [[ $line -eq '- Exception from external service:' ]] ;
then
echo "Subject: Samba is Down "| /usr/sbin/sendmail -f [email protected]
-t [email protected],
fi
done
答案1
回声处的管道末尾有一个逗号。翻新一下就应该没问题了。