微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

写一个shell脚本,当mysql表超过50行时显示alert

如何解决写一个shell脚本,当mysql表超过50行时显示alert

我在 MysqL 中有一个表,我想显示警报或消息,告诉我我的记录是否超过 50 行。

解决方法

运行查询以计算表中的条目数,然后使用 grep 解析输出。

 if [ $(mysql --user=<username> --password=<password> -e "select COUNT(<primary key>) from <database>.<table>" | grep -E '[[:digit:]]+') -gt "50" ];
 then 
     echo "Rows are greater then 50";
 fi
,
This expression is not callable. Each member of the union type '/* Route info here */' has signatures,but none of those signatures are compatible with each other.ts(2349)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。