邮件未发送到目的地

邮件未发送到目的地
#!/bin/bash

SUBJECT="WARNING CPU USAGE HIGH"
[email protected]
MESSAGE=/tmp/messages
echo "#######################" > $MESSAGE
echo "CPU statistics as follows.." >> $MESSAGE
mpstat >> $MESSAGE
echo "#######################" >> $MESSAGE
CPU_USAGE=$(top -b -n1 | awk '/^%Cpu/ {print $2}' | cut -d. -f1)

[ "$CPU_USAGE" -gt 1 ] && mail -s "$SUBJECT" "$TO" < $MESSAGE

一旦 CPU 使用率超过限制,上述脚本就会发送一封邮件。尽管我在代码中规定了一个有效的 gmail id,但它仍然会将邮件发送到/var/mail/root。如何解决这个问题?我按照下面的链接做了必要的更改。但/var/mail/root显示

Return-Path: <root@server2-SandyBridge-Platform>
Received: by server2-SandyBridge-Platform (Postfix, from userid 0)
        id A4977138269C; Fri, 14 Oct 2016 10:53:11 +0530 (IST)
Subject: WARNING CPU USAGE HIGH
To: <[email protected]>
X-Mailer: mail (GNU Mailutils 2.99.98)
Message-Id: <20161014052311.A4977138269C@server2-SandyBridge-Platform>
Date: Fri, 14 Oct 2016 10:53:11 +0530 (IST)
From: root@server2-SandyBridge-Platform (root)

#######################
CPU statistics as follows..
Linux 3.13.0-98-generic (server2-SandyBridge-Platform)  Friday 14 October 2016  _x86_64_        (4 CPU)

10:53:11  IST  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
10:53:11  IST  all    3.07    0.15    1.13    1.48    0.00    0.01    0.00    0.00    0.00   94.17
#######################`
There is no mail in my mail id though.@Terrance

相关内容