shell读取数据库

 #/bin/sh
#时间
year=`date --date= +%Y`
month=`date --date= +%m`
day=`date --date="1 day  ago" +%d`
mysql=" /usr/local/mysql/bin/mysql -h127.0.0.1 -uroot -proot jp_union -e "

sql=" select count(*) from unionsite where year(createTime)='$year' and month(createTime)='$month' and day(createTime)='$day' "

result=$($mysql "$sql");


echo $mysql
echo $sql
echo $result
~            

你可能感兴趣的:(shell读取数据库)