ITeye博客

shell 脚本 实现简单的定时查库发邮件

wangmingming2008 · 2013-08-22 11:12 · 2013 · 互联网 · Markdown

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 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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。