download_data.sh 826 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. abs_path=$(cd `dirname $0`; pwd)
  3. start_date=""
  4. end_date=""
  5. if(($#==2))
  6. then
  7. start_date=$1
  8. end_date=$2
  9. else
  10. start_date=$(date +%Y%m%d -d "-2 $days day")
  11. end_date=$start_date
  12. fi
  13. partition=64
  14. hdfs_url="hdfs://192.168.141.208:9000"
  15. hdfs_path="/dw/recommend/model/831_recsys_rov_train_data"
  16. local_path="${abs_path}/../data"
  17. for((i=0; i<=21; i++))
  18. do
  19. data_date=$(date -d "$start_date $i day" +"%Y%m%d")
  20. if [ "$data_date" -le "$end_date" ]
  21. then
  22. for((j=0; j<$partition; j++))
  23. do
  24. hdfs_file=$(printf "%s/%s/part-%05d.gz" $hdfs_path $data_date $j)
  25. local_file=$(printf "%s/%s_%05d.csv" $local_path $data_date $j)
  26. echo `date` " hdfs dfs -fs $hdfs_url -text $hdfs_file > $local_file"
  27. hdfs dfs -fs $hdfs_url -text $hdfs_file > $local_file
  28. sleep 1s
  29. done
  30. fi
  31. done