ran5000 icon

import s_relations

ran5000 | PRO | 10/02/12 10:15:08 AM UTC | 0 ⭐ | 346 👁️ | Never ⏰ | []
Bash |

1.17 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
STOP_FILE=stop.txt
SLEEP_TIME=4 #seconds
LOGFILE=jinji_job.log
SPLIT_FOLDER=change_s_relations
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.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
        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