View difference between Paste ID: Q4JfPRf9 and YxGuR527
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_messages
5+
SPLIT_FOLDER=change_twitter_statuses
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.messages_new FIELDS TERMINATED BY ','  LINES TERMINATED BY '\n'  (\`id\`,\`concrete_message_type\`,\`concrete_message_id\`,\`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.twitter_statuses_new FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' (id,status_twitter_id,twitter_id,creator_twitter_identity_id,@text,in_reply_to_status_id,in_reply
22
_to_user_id,@urls,@hashtags,created_at,updated_at,sent_at,@user_mentions) set text=replace(@text,'\\\n', '\n'), urls=replace(@urls,'\\\n', '\n'), hashtags=replace(@hashtags,
23
'\\\n', '\n'), user_mentions=replace(@user_mentions,'\\\n','\n');" >> $LOGFILE
24
        echo $(date) "Done processing $f, moving to done folder" >> $LOGFILE
25
        mv $f "processed"
26
        echo "Sleeping for $SLEEP_TIME seconds" >> $LOGFILE
27
        sleep $SLEEP_TIME
28
done