写一个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)