LinuxMail发送邮件
使用Mail命令发送邮件:
可如下所示 echo "hello,echo"|mail -s "echo" justin@51cto.com
#!/bin/bash
HOST=$1;
DATABASE=$2;
TIMESTAMP=`date +%Y%m%d`;
RECEIVER=$3;
#execute sql stat
cmd="SELECT COUNT(*) FROM ${DATABASE}.XXX WHERE XXX";
cnt=$(mysql -h${HOST} -uxxxx -pxxxx -s -e "${cmd}");
if [ $cnt -gt 0 ]
then
echo "${TIMESTAMP}共:${cnt}人,请及时查看。"|mail -s "核对" ${RECEIVER}
fi
exit;
需要依赖于mailutils,若没有安装,请先安装【针对ubuntu 】