View difference between Paste ID: YxGuR527 and vvZ7cjBW
SHOW: | | - or go back to the newest paste.
1
#!/bin/bash
2
STOP_FILE=stop.txt
3
SLEEP_TIME=4 #seconds
4
LOGFILE=jinji_job.log
5-
SPLIT_FOLDER=change_s_relations
5+
SPLIT_FOLDER=change_messages
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
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.messages_new FIELDS TERMINATED BY ','  LINES TERMINATED BY '\n'  (\`id\`,\`concrete_message_type\`,\`concrete_message_id\`,\`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