歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> SHELL編程

shell腳本實現簡單的定時查庫發郵件

shell腳本實現簡單的定時查庫發郵件   shell mysql mail vi 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   [email protected] [email protected] [email protected] [email protected] < /root/action_shell/$last_date.data  
Copyright © Linux教程網 All Rights Reserved