#!/bin/bash
#set -o nounset                              # Treat unset variables as an error
#set -m                                      # Enable job control

source ~/.bashrc

echo $PATH 1>&2

PREV_TEN_MINUTES_DATE="$(date -d "-10 minutes" +"%Y/%m/%d %H:%M"|head -c 15)"

rm -rf /tmp/log2any_tmp_test

for MissionServerDir in ~/server*/MissionServer*;do

        # Account Mail log for AID 6
        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
        export SET=999

        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
        )|egrep -v '매일 접속 선물|Li'|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_aid_6 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

for MissionServerDir in ~/server*/MissionServer*;do

        # Account Mail log for AID 5
        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
        export SET=999

        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
        )|egrep -v '매일 접속 선물|Li'|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_aid_5 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

for MissionServerDir in ~/server*/MissionServer*;do

        # Account Mail log for AID 4
        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
        export SET=999

        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
        )|egrep -v '매일 접속 선물|Li'|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_aid_4 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

for MissionServerDir in ~/server*/MissionServer*;do

        # Account Mail log for AID 3
        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
        export SET=999

        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
        )|egrep -v '매일 접속 선물|Li'|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_aid_3 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

for MissionServerDir in ~/server*/MissionServer*;do

        # Account Mail log for AID 2
        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
        export SET=999

        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
        )|egrep -v '매일 접속 선물|Li'|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_aid_2 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

for MissionServerDir in ~/server*/MissionServer*;do

        # Account Mail log for AID 1
        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
        export SET=999

        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
        )|egrep -v '매일 접속 선물|Li'|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_aid_1 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

#for MissionServerDir in ~/server*/MissionServer*;do
#
#        # Account Mail log for CID 5
#        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
#        export SET=999
#
#        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
#                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
#        )|egrep -v '每日登入贈禮|Li'|sed "s/'/''/g" |\
#	nice -19 ~/bin/log2any.py account_mail_cid_5 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log
#
#done
#
#for MissionServerDir in ~/server*/MissionServer*;do
#
#        # Account Mail log for CID 4
#        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
#        export SET=999
#
#        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
#                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
#        )|egrep -v '每日登入贈禮|Li'|sed "s/'/''/g" |\
#	nice -19 ~/bin/log2any.py account_mail_cid_4 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log
#
#done
#
#for MissionServerDir in ~/server*/MissionServer*;do
#
#        # Account Mail log for CID 3
#        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
#        export SET=999
#
#        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
#                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
#        )|egrep -v '每日登入贈禮|Li'|sed "s/'/''/g" |\
#	nice -19 ~/bin/log2any.py account_mail_cid_3 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log
#
#done
#
#for MissionServerDir in ~/server*/MissionServer*;do
#
#        # Account Mail log for CID 2
#        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
#        export SET=999
#
#        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
#                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
#        )|egrep -v '每日登入贈禮|Li'|sed "s/'/''/g" |\
#	nice -19 ~/bin/log2any.py account_mail_cid_2 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log
#
#done

for MissionServerDir in ~/server*/MissionServer*;do

        # Account Mail log for CID 1
        [ -d $MissionServerDir ] && cd $MissionServerDir || continue
        export SET=999

        grep -h "^[ 0-9]\+,$PREV_TEN_MINUTES_DATE" $(
                ls -tr AccountMail*.log.* 2> /dev/null|tail -2
        )|egrep -v '매일 접속 선물|Li'|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_cid_1 $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

