ran5000 icon

Untitled

ran5000 | PRO | 10/19/12 12:30:27 PM UTC | 0 ⭐ | 344 👁️ | Never ⏰ | []
Bash |

1.33 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
STOP_FILE=stop.txt
SLEEP_TIME=4 #seconds
LOGFILE=jinji_job.log
SPLIT_FOLDER=change_twitter_statuses
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.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
_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,
'\\\n', '\n'), user_mentions=replace(@user_mentions,'\\\n','\n');" >> $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

Comments