日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Ubuntu >内容正文

Ubuntu

Ubuntu用命令行发邮件mutt,报警发短信通知

發(fā)布時間:2025/4/5 Ubuntu 57 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ubuntu用命令行发邮件mutt,报警发短信通知 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

在ubuntu下用sendmail有點問題,主題發(fā)出去老為空。

干脆安裝mutt和msmtp,通過163的郵件系統(tǒng)發(fā)郵件。

sudo?apt-get?install?mutt,另外需要安裝msmtp,一個發(fā)郵件的小工具,sudo?apt-get?install?msmtp

配置mutt

?1、在?/etc/Muttrc?文件里最后加入5行

set?sendmail="/usr/bin/msmtp"
set?use_from=yes
set?realname="mozatmonitor"?????---》發(fā)件人顯示昵稱
set?from=mozatmonitor@163.com?????--》發(fā)件人地址
set?envelope_from=yes

-----------------如有編碼問題可以嘗試在后面加入----

set?charset="utf-8"
#set?send_charset="gb2312"
set?send_charset="utf-8"
set?locale?=?"zh_CN.UTF-8"
set?content_type?=?"text/html\;charset=utf-8"

?

2、編輯~/.msmtprc,如果這個文件不存在就創(chuàng)建一個,要錄屬于當(dāng)前用戶和群組,該文件需要600權(quán)限,如果不是600權(quán)限會無法使用。

account?default
host?smtp.163.com???????????????---->郵件服務(wù)器地址
from?mozatmonitor@163.com????
auth?login???????????????????????????------>?認(rèn)證方式用最傻的login
user?mozatmonitor
password?kkkkkk????????????????????----->kkkkkk替換成密碼
logfile?~/.msmtp.log

?

?

發(fā)送:

mutt?-s?"主題"?foo@sina.com.cn?-a?附件.txt?<郵件內(nèi)容.txt

多聯(lián)系人多附件:

MailList=`cat?list.txt`

/usr/bin/mutt??-s?"主題"?$MailList?-a?附件1?-a?附件2??<?hello.txt

?

?##報警發(fā)郵件

1、扔腳本在后臺導(dǎo)入數(shù)據(jù)(這個腳本包含計算腳本運行時間):nohup?./import.sh?&

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 mozat@DellR410-DB4:~$?cat?import.sh??? #!/bin/bash ???? BEGINTIME=`date?+"%Y-%m-%d?%H:%M:%S"` ???? /usr/local/mysql-5.5.15/bin/mysql??-h?127.0.0.1?-P?3335??-uxxx?-pxxxxxx?<?/home/mozat/xxx.sql ???? ENDTIME=`date?+"%Y-%m-%d?%H:%M:%S"` begin_data=`date?-d??"$BEGINTIME"?+%s`????#把當(dāng)前時間轉(zhuǎn)化為Linux時間 end_data=`date?-d??"$ENDTIME"?+%s` spendtime=`expr?$end_data?-?$begin_data`??#計算2個時間的差 ???? ???? echo?"it?takes?$spendtime?sec?for?dump?the?data?directory" echo?"it?takes?$spendtime?sec?for?dump?the?data?directory"?>/tmp/dump184_3335mofs2.txt

?2、在crontab中每分鐘跑監(jiān)控腳本,如果發(fā)現(xiàn)跑完,就發(fā)郵件給139郵件,這樣手機就會收到短信。

?

1 2 3 4 5 6 7 8 9 10 11 mozat@DellR410-DB4:~$?crontab?-l */1?*?*?*?*?/bin/sh??/home/mozat/operation/xx/sendmail.sh mozat@DellR410-DB4:~$?cat??/home/mozat/operation/xx/sendmail.sh #!/bin/bash ??? counter=`ps?-ef?|?grep?import.sh?|?grep?-v?grep?|wc?-l` if?[?$counter?-eq?0?];?then ????????/usr/bin/mutt?-s?"back?is?finished"?13xxxxx@139.com?</home/mozat/operation/xx/hello.txt else ????????echo?"the??backup?is?running?now." fi

轉(zhuǎn)載于:https://www.cnblogs.com/vk83/archive/2013/06/01/3112454.html

總結(jié)

以上是生活随笔為你收集整理的Ubuntu用命令行发邮件mutt,报警发短信通知的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。