shell指令碼實現簡單的定時查庫發郵件

來源:互聯網
上載者:User

shell指令碼實現簡單的定時查庫發郵件 shell mysql mailvi ip.txt  #iostest_tw=10.52.*.* #iostest_kr=10.52.*.* imop_tw_s1=10.52.*.* imop_tw_s2=10.52.*.* imop_tw_s3=10.52.*.* ko_kr_s1=10.52.*.*  #每天早上10點執行 crontab -e 00 10 * * * /root/action_shell/export.sh >> /root/action_shell/mail.log  #! /bin/sh  last_data=$(date -d last-day +%Y_%m_%d); cat /dev/null > $last_data.date for s_ip in $(awk -F= '{print $0}' /root/action_shell/ip.txt); do         echo ===============================start to do task===================================================;         s=$(echo $s_ip|awk -F= '{print $1}');         ip=$(echo $s_ip|awk -F= '{print $2}');          echo '====================='$s'_level_top_10==============================================' >>$last_date.data          out1=$(mysql -h$ip -u*** -p*** -Dgen_log -e 'select id,account_id,account_name,char_id,char_name,max(level),from_unixtime(createTime/1000)  from pet_level_log_'$last_data' group by account_id  order by max(level) desc,createTime  limit 10;' >> /root/action_shell/$last_date.data);  echo '====================='$s'_frist_to_pass_zhangliao_10==============================================' >>$last_date.data         out2=$(mysql -h$ip -uxxx -pxxxx -Dgen_log -e 'select id,log_time,account_id,char_id,account_name,char_name,param from property_change_log_'$last_data' where SUBSTRING(param,13)=1297 order by id limit 10;' >> /root/action_shell/$last_date.data);          echo $out1;         echo $out2;          sleep 10         echo ===============================send mail successfully===================================================; done   /bin/mail -s 'from games.asia team tech '_$last_data   wu_tong@renren-inc.com mingming.wang@renren-inc.com yongliang.yang@renren-inc.com yuesong.pu@renren-inc.com < /root/action_shell/$last_date.data 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.