Shell script to implement simple timed database check and Mail
Last Update:2014-05-15
Source: Internet
Author: User
Shell script implements simple timed database check and email sending; ** iostest_kr1052 ** imop_tw_s11052 ** interval ** imop_tw_s31052 ** ko_kr_s11052 ** each shell script implements simple timed database check and email 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. *. * # run crontab-e 00 10 ***/root/action_shell/export at every day. 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