Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- STOP_FILE=stop.txt
- SLEEP_TIME=5 #seconds
- LOGFILE=jinji_job.log
- SPLIT_FOLDER=change_feed_items
- echo "Starting the JINJI JOB!!!!!!!!!!!!!!!!!!!!" >> $LOGFILE
- if [ ! -d "processed" ]
- then
- echo "creating done folder" >> $LOGFILE
- mkdir "processed"
- fi
- for f in splited*;
- do
- if [ -f $STOP_FILE ]
- then
- echo "Stop file found - stopping..." >> $LOGFILE
- break
- fi
- echo "Processing $f file..." >> $LOGFILE
- echo $(date) "Starting SQL Command" >> $LOGFILE
- 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.feed_items_new FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (\`id\`,\`member_id\`,\`item_type\`,\`occured_at\`,\`created_at\`,\`updated_at\`,\`user_id\`,\`s_object_monitor_id\`,\`rating\`);" >> $LOGFILE
- echo $(date) "Done processing $f, moving to done folder" >> $LOGFILE
- mv $f "processed"
- echo "Sleeping for $SLEEP_TIME seconds" >> $LOGFILE
- sleep $SLEEP_TIME
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement