网站地图    收藏   

主页 > 后端 > mysql数据库 >

shell脚本调用mysql存储过程 - mysql数据库栏目 - 自

来源:自学PHP网    时间:2015-04-16 10:51 作者: 阅读:

[导读] ! bin sh The function of the script is used to balance statistics,we get data from the table accseqs,after the analysis and calculation data, the results w...

#!/bin/sh

##  The function of the script is used to balance statistics,we get
##  data from the table accseqs,after the analysis and calculation data,
##  the results will be inserted into the table acc_balances.

##  the script is executed at 1 o'clock by every day.

DIR="/var/www/apps/sql"
DATE=$(date +%Y%m%d --date '1 days ago')
HOST=192.168.20.95
USER=admin
PASSWD=000000
DATABASE=zhxt
FILE=result.txt

cd ${DIR}

echo "the date:"${DATE}

SQL="exec mysql -h${HOST} -u${USER} -p${PASSWD} -D ${DATABASE} --default-character-set=utf8 -e \"call query_balance(${DATE})\""
echo ${SQL}>>${FILE}

if   mysql -h${HOST} \
           -u${USER} \
           -p${PASSWD} \
           -D ${DATABASE} \
           --default-character-set=utf8 \
           -e "call query_balance(${DATE})"; then
    echo "ok">>${FILE}
else
    echo "fail">>${FILE}
fi

exit


自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论