這應該是比較簡單的,但我從來沒有碰到過它,現在我正在撓頭。電子郵件中的所有行一起運行
簡單腳本:
echo `tail /var/log/qmailcheck.log` >> $EMAIL
cat $EMAIL | mail -s "Daily server report from server.ca" [email protected]
(我知道我錯過了一組蜱圍繞tail
CMD只是想事情右看看)
的問題是,雖然日誌文件我中號尾礦出了對每個條目的新行被髮送的電子郵件把一切都在一個行,以便取而代之的是:
Mon Feb 4 11:05:01 MST 2013-- Check Completed Successfully
Mon Feb 4 11:10:01 MST 2013-- Check Completed Successfully
Mon Feb 4 11:15:01 MST 2013-- Check Completed Successfully
Mon Feb 4 11:20:01 MST 2013-- Check Completed Successfully
Mon Feb 4 11:25:01 MST 2013-- Check Completed Successfully
我得到這個:
Mon Feb 4 11:05:01 MST 2013-- Check Completed Successfully Mon Feb 4 11:10:01 MST 2013-- Check Completed Successfully Mon Feb 4 11:15:01 MST 2013-- Check Completed Successfully Mon Feb 4 11:20:01 MST 2013-- Check Completed Successfully Mon Feb 4 11:25:01 MST 2013-- Check Completed Successfully
該腳本還呼應的,從其他一些命令,他們似乎也碰上一條線,以及,我已經這樣做過,但從來沒有一個問題,我缺少什麼?
這裏是整個腳本:
ERROR=/tmp/errorlog
RECIP=$(cat /root/bin/emailrec)
echo Hi, this email to inform you of any potential issues with the server.bla qmail mail server > /tmp/demail
grep pls /var/log/qmailcheck.log > /tmp/errorlog
if [ ! -s $ERROR ] ; then
echo There are no errors in the qmailcheck log file >> /tmp/demail
echo Here are the last 10 lines of the current qmailcheck log file: >> /tmp/demail
tail /var/log/qmailcheck.log >> /tmp/demail
else
echo The log file for the qmail check script contains the following errors: >> /tmp/demail
cat $ERROR >> /tmp/demail
echo You should have also received an email which will better explain the error >> /tmp/demail
echo Check the time of the error above to determine when the email was sent >> /tmp/demail
fi
MAIL=$(/var/qmail/bin/qmail-qstat | grep "queue:" | awk '{ print $4 }')
echo There are $MAIL messages in the mail queue >> /tmp/demail
echo File system usage is currently at `df -h |grep vzfs | awk '{ print $5}'` >> /tmp/demail
cat /tmp/demail | mail -s "Daily server report from server.bla" $RECIP
更新的腳本中沒有任何內容會導致行被合併。我懷疑你的郵件閱讀器正在包裝線。與消息的原始來源比較。 – Barmar