#!/bin/bash
#owner:bi
#cronTime:
#inputData:WORDBANK
#describe:export data from WORDBANK to host 240
#note:
source /etc/profile
ik_dir='/opt/cms_syc_seg/useDic/ik/stopword'
stoppool='/auto_cron/cron-running/dam/cy_ad_dat/stoppool'
ansj_dir='/opt/cms_syc_seg/useDic/ansj'
ik_dir_opt='/opt/bin/UDF/useDic/ik/stopword'
# export data in one file
mysql -h"10.***.3.***" -u"bi" -p'****' -Ne "set names utf8; SELECT wordname FROM WORDBANK.stop_relation_bank WHERE flag=2" > ${ansj_dir}/stopword.txt
echo ${ansj_dir}/stopword.txt finished!
# export the name list to file
mysql -h"10..3.2" -u"w" -p'****' -Ne "set names utf8; select distinct bankname from WORDBANK.wordbank where flag=0;" > ${ik_dir}/'bankname.txt'
list=`cat ${ik_dir}/bankname.txt`
# loop
for i in $list;do
# create dir
if [ ! -d ${ik_dir}/$i ];then
mkdir ${ik_dir}/${i}
fi
if [ ! -d ${stoppool}/$i ];then
mkdir ${stoppool}/${i}
fi
# export data in each file
mysql -h"10..3.218" -u"w" -p'34' -Ne "set names utf8; select wordname from WORDBANK.stop_relation_bank where bankname='${i}' " > ${stoppool}/${i}/${i}.txt
cp ${stoppool}/${i}/${i}.txt ${ik_dir}/${i}.txt
echo ${ik_dir}/${i}.txt ${stoppool}/${i}/${i}.txt finished!
# end loop
done
cp -r ${stoppool}/* ${ik_dir_opt}/
mysql---备份数据
最新推荐文章于 2022-07-21 16:15:29 发布