ITPub博客

首页 > 数据库 > MySQL > 每隔30秒循环收集MYSQL备库状态信息的SHELL脚本

每隔30秒循环收集MYSQL备库状态信息的SHELL脚本

原创 MySQL 作者:lixiaxin200319 时间:2016-09-15 19:52:04 0 删除 编辑
slave_status.sh

x=0
while  [  $x -lt  50 ]
do
    mysql -u root -proot_tcl -e "show slave status \G" >> slave_status.txt
    x=`expr $x + 1`

    echo  '#########################################################################' >> slave_status.txt
    sleep 10
done
 


下面的脚本是使用 expect 在脚本中自动输入密码
x=0
while  [  $x -lt  50 ]
do
   expect <<EOF
    spawn mysql -u root -p -e "show slave status\\\G"
    expect "*password:"
    send "Ky_qmt@0414\r"
    expect eof
EOF
    x=`expr $x + 1`

    echo  '#########################################################################' >> slave_status.txt
    sleep 10
done

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21582653/viewspace-2125022/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-02-10

  • 博文量
    66
  • 访问量
    208501