1、count_ID.sh
#!/bin/bash
for ((i=0;i<3000;i++))
do
ct=`mysql -h 192.168.60.154 -P 3308 --database=vim -BNe"select count(*) from vehicle_partition where RoadMonitorStationId_=$i;"`
at=300000
if [ $ct -lt $at ]; then
echo "$i"
echo "RoadMonitorStationId_= $i" >>/opt/opaq/count.txt
echo "$ct"
echo "COUNT = $ct" >>/opt/opaq/count.txt
sleep 1
fi
done
-BNe 中的 -N是去掉列名显示。
也可以去掉-N参数,换用awk来去掉列名,由于列名是第一行: ...RoadMonitorStationId_=$i;"|awk 'NR>1'
另外用if 时,注意空格
2、count_time.sh
#!/bin/bash
for ((i=1;i<41;i++))
do
date1='2014-04-30 00:00:15'
date2=`date +%Y-%m-%d -d "+"$i"days $date1"`
date3=`date +%Y-%m-%d -d "+1days $date2"`
echo "$date2"
echo "$date3"
ct=`mysql -h 192.168.60.154 -P 3308 --database=vim -BNe"select count(*) from vehicle_partition where AccessTime_ between '$date2 00:06:29'
and '$date3 00:06:29';"`
echo "$ct"
done
阅读(1770) | 评论(0) | 转发(0) |