mysql数据定时导入脚本(shell)

mysql数据定时导入脚本(shell)

在服务器上发现的定时的导入脚本,记录下来。还是很有用的
30 06 * * * /data/dmsp/shell/crontab_search_stats_import.sh >> /data/dmsp/logs/crontab_search_stats_import.log
# !/bin/sh

y
= $(date  - " -1 day "   +% Y)
m
= $(date  - " -1 day "   +% m)
d
= $(date  - " -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  [  - " ${statpath} "  ] ; then
              tar xjf ${mypath}${act}${y}${m}${d}.tar.bz2 
- C ${mypath}
                mysql 
- 127.0 . 0.1   - P3306  - u root  - pmysql  - " 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




整理 www.blogjava.net/Good-Game

你可能感兴趣的:(mysql数据定时导入脚本(shell))