#!/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
        [ -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
        )|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_aid $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

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

        # Account Mail log for CID
        [ -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
        )|sed "s/'/''/g" |\
	nice -19 ~/bin/log2any.py account_mail_cid $SET 1>>/tmp/log2any_tmp_test 2>> ~/log2db_debug.log

done

