在服务器上发现的定时的导入脚本,记录下来。还是很有用的
30 06 * * * /data/dmsp/shell/crontab_search_stats_import.sh >> /data/dmsp/logs/crontab_search_stats_import.log
本文转自博客园刘凯毅的博客,原文链接:mysql数据定时导入脚本(shell),如需转载请自行联系原博主。
30 06 * * * /data/dmsp/shell/crontab_search_stats_import.sh >> /data/dmsp/logs/crontab_search_stats_import.log
#
!/bin/sh
y = $(date - d " -1 day " +% Y)
m = $(date - d " -1 day " +% m)
d = $(date - d " -1 day " +% d)
# /data/dmsp/ftp/dim_stats/2009/09/14
act = dim_stats
mypath =/ data / dmsp / ftp / ${act} / ${y} / ${m} / ${d} /
echo $mypath
statpath = ${mypath}${act}${y}${m}${d}.tar.bz2.state
for (( j = 1 ; j < 10000 ; j = j + 1 ))
do
if [ - d " ${statpath} " ] ; then
tar xjf ${mypath}${act}${y}${m}${d}.tar.bz2 - C ${mypath}
mysql - h 127.0 . 0.1 - P3306 - u root - pmysql - e " LOAD DATA INFILE '${mypath}part-00000' INTO TABLE dmsp.dmsp_veidoo character set utf8 FIELDS TERMINATED BY '\t' lines terminated by '\n' " ;
break
else
echo " [${j}:1000] not ready. sleep 10 seconds then retry. "
sleep 10
fi
don
y = $(date - d " -1 day " +% Y)
m = $(date - d " -1 day " +% m)
d = $(date - d " -1 day " +% d)
# /data/dmsp/ftp/dim_stats/2009/09/14
act = dim_stats
mypath =/ data / dmsp / ftp / ${act} / ${y} / ${m} / ${d} /
echo $mypath
statpath = ${mypath}${act}${y}${m}${d}.tar.bz2.state
for (( j = 1 ; j < 10000 ; j = j + 1 ))
do
if [ - d " ${statpath} " ] ; then
tar xjf ${mypath}${act}${y}${m}${d}.tar.bz2 - C ${mypath}
mysql - h 127.0 . 0.1 - P3306 - u root - pmysql - e " LOAD DATA INFILE '${mypath}part-00000' INTO TABLE dmsp.dmsp_veidoo character set utf8 FIELDS TERMINATED BY '\t' lines terminated by '\n' " ;
break
else
echo " [${j}:1000] not ready. sleep 10 seconds then retry. "
sleep 10
fi
don
本文转自博客园刘凯毅的博客,原文链接:mysql数据定时导入脚本(shell),如需转载请自行联系原博主。