tb_name=mysql -u账号 -p密码 -h192.168.x.x -P端口 -e "select table_name from information_schema.tables where table_schema=‘数据库名‘"|awk ‘NR>1{print $1}‘
for name in $tb_name ;
do
tbl_count=mysql -u账号 -p密码 -h192.168.x.x -P端口 -e "select count (*) as times from cwsys.$name;"| tail -1
echo "$name=$tbl_count" >>/home/xxx/xxx.log
done
执行脚本:
查看生成的统计记录:
查看统计数据:
原文:http://blog.51cto.com/jdonghong/2351689