How to capture a column values form SHOW SLAVE STATUS

纵饮孤独 提交于 2019-12-13 07:38:14

问题


I need to capture a value of "seconds_behind_master" column.

SHOW SLAVE STATUS;

How to achieve it ?


回答1:


In a shell script or on the command line on Linux you could:

SECONDS_BEHIND=$(mysql -usome_user -psome_pass -e "show slave status" -E | grep "Seconds_Behind_Master:" | cut -d: -f2)



回答2:


SECONDS=$(mysql -uuser -ppass -Pport -e"show slave status\G" grep Seconds_Behind_Master | awk '{print $2}')


来源:https://stackoverflow.com/questions/39850240/how-to-capture-a-column-values-form-show-slave-status

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!