Advertisement
ran5000

import s_relations

Oct 2nd, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.17 KB | None | 0 0
  1. #!/bin/bash
  2. STOP_FILE=stop.txt
  3. SLEEP_TIME=4 #seconds
  4. LOGFILE=jinji_job.log
  5. SPLIT_FOLDER=change_s_relations
  6. echo "Starting the JINJI JOB!!!!!!!!!!!!!!!!!!!!" >> $LOGFILE
  7. if [ ! -d "processed" ]
  8. then
  9.         echo "creating done folder" >> $LOGFILE
  10.         mkdir "processed"
  11. fi
  12. for f in splited_*;
  13. do
  14.         if [ -f $STOP_FILE ]
  15.         then
  16.                 echo "Stop file found - stopping..." >> $LOGFILE
  17.                 break
  18.         fi
  19.         echo "Processing $f file..." >> $LOGFILE
  20.         echo $(date) "Starting SQL Command" >> $LOGFILE
  21.         mysql -uroot -p'gr$ppl!' --local-infile=1 -e "SET SESSION binlog_format='ROW'; LOAD DATA LOCAL INFILE '/srv/$SPLIT_FOLDER/$f' INTO TABLE communit_pablo.s_relations_new FIELDS TERMINATED BY ','  LINES TERMINATED BY '\n'  (\`source_persona_id\`,\`relation_type\`,\`message_id\`,\`reply_to_message_id\`,\`reshare_of_message_id\`,\`target_object_id\`,\`target_persona_id\`,\`created_at\`,\`updated_at\`,\`sent_at\`);" >> $LOGFILE
  22.         echo $(date) "Done processing $f, moving to done folder" >> $LOGFILE
  23.         mv $f "processed"
  24.         echo "Sleeping for $SLEEP_TIME seconds" >> $LOGFILE
  25.         sleep $SLEEP_TIME
  26. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement