Chinaunix首页 | 论坛 | 博客
  • 博客访问: 478679
  • 博文数量: 99
  • 博客积分: 3621
  • 博客等级: 中校
  • 技术积分: 1089
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-22 16:29
文章存档

2012年(21)

2011年(28)

2010年(50)

分类: Python/Ruby

2011-09-26 10:16:19

  1. [bzuo@devdb1 ~]$ cat check_table.sh
  2. #check table when flush complete,if table crushed then repair it
  3. #first parameter is DB name.
  4. #!/bin/sh
  5. if [ -z $1 ];then #if the length of DB name is zero
  6.    echo 'Please input DB name'
  7.    exit 0
  8. fi

  9. if [ -f /home/bzuo/log.log ];then #just save one time result
  10.    rm -rf /home/bzuo/log.log
  11. fi

  12. for table in `mysql -uroot -p123 -e "use $1;show tables" | awk '{if(NR>1) print $0}'` #get all tables
  13. do
  14.         mysql -uroot -p123 -e "explain select * from $1.$table limit 1" >> /home/bzuo/log.log 2>&1 || `mysql -uroot -p123 -e "repair table $1.$table" >> /home/bzuo/log.log 2>&1`
  15. done
阅读(913) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~