傳送統計郵件shell指令碼

2022-06-23 20:24:09 字數 1537 閱讀 4897

user="aaa"

port="3306"

password="aaa"

database="aaa"

today="$(date +%y-%m-%d)"

yesterday="$(date +%y-%m-%d --date="-1 day")"

host="aaa"

send_mail_name=("[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]")

#表py_weixin_product_close_rating_info當天資料條數sql

sql_tableclose_today_count="select count(*) from py_weixin_product_close_rating_info where report_date='$';"

#表py_weixin_product_close_rating_info前一天資料條數sql

sql_tableclose_yesterday_count="select count(*) from py_weixin_product_close_rating_info where report_date='$';"

#表py_weixin_product_open_rating_info當天資料條數統計sql

sql_tableopen_today_count="select count(*) from py_weixin_product_open_rating_info where report_date='$';"

#表py_weixin_product_open_rating_info前一天資料統計條數sql

sql_tableopen_yesterday_count="select count(*) from py_weixin_product_open_rating_info where report_date='$';"

#將當天和前一天的記錄條數統計

num_close_today=$($ "$" 2>/dev/null | sed '1d')

num_close_yesterday=$($ "$" 2>/dev/null | sed '1d')

#將當天和前一天的記錄條數統計

num_open_today=$($ "$" 2>/dev/null | sed '1d')

num_open_yesterday=$($ "$" 2>/dev/null | sed '1d')

function send_mail()

日 統計記錄條數為: $ 條;

$日 統計記錄條數為: $ 條。

2、開放式表:

$日 統計記錄條數為: $ 條;

$日 統計記錄條數為: $ 條。" | mail -s "表記錄統計結果" $1

} #傳送郵件

for name in $

dosend_mail $name

done

linux傳送郵件的shell指令碼

bin sh function echo help email to toaddress.emailname test mail messagebody tmp.tmp from from fromaddress.fromname mailreport subject mail report unt...

Shell 傳送郵件

1.確認mail安裝 rpm qa grep mail 如未安裝 yum install mailx ll usr bin mail 2.配置郵箱設定項 引用外部smtp伺服器 etc mail.rc set from telent qq.com set smtp smtp.qq.com set s...

linux通過shell指令碼傳送網路郵件

很多運維人員在做一些簡單監控的指令碼時,需要對監控內容能夠及時反饋,比如監控cpu使用率達到50 就會收到警告,這時候郵件起了很大的作用,那麼如何在shell指令碼中呼叫郵件工具呢,這裡有乙個簡便的方法 這時我們需要把登入資訊下如mail程式 在檔案 etc mail.rc中新增如下兩行 set f...