38 lines
1.3 KiB
Bash
38 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
BLACKCUBE_ROOT=/
|
|
BLACKCUBE_CONF=/conf
|
|
|
|
BASE=`dirname $(pwd)/$0`
|
|
INCDIR="$BASE/include"
|
|
RESOURCE="$BASE/resource"
|
|
|
|
. $INCDIR/*.sh
|
|
exec 11>&1 12>&2
|
|
exec &>>$RUN_LOG
|
|
##############################
|
|
|
|
MYSQLPWD=`grep jdbc.password /opt/bksoft/ubackup/conf/jdbc.properties | cut -c 15-`
|
|
MYSQLUSER=`grep jdbc.username /opt/bksoft/ubackup/conf/jdbc.properties | cut -c 15-`
|
|
|
|
SQL_TABLES="SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='unary' AND TABLE_NAME regexp 'tbl_jobhistory(_2)|^tbl_jobhistory$'"
|
|
RESULT_TABLES=`mysql -u$MYSQLUSER -p$MYSQLPWD -e "$SQL_TABLES" 2>/dev/null|awk 'NR>1'`
|
|
for i in $RESULT_TABLES
|
|
do
|
|
INFOTABLE="tbl_jobhistory_info"${i:14}
|
|
TASKIDS=`mysql -u$MYSQLUSER -p$MYSQLPWD -e "select taskid from unary.$i where level=3" 2>/dev/null|awk 'NR>1'`
|
|
for j in $TASKIDS
|
|
do
|
|
INFOSNS=`mysql -u$MYSQLUSER -p$MYSQLPWD -e "select info_sn from unary.$INFOTABLE where taskid='$j'" 2>/dev/null|awk 'NR>1'`
|
|
mysql -u$MYSQLUSER -p$MYSQLPWD -e "delete from unary.$INFOTABLE where taskid='$j'" 2>/dev/null|awk 'NR>1'
|
|
mysql -u$MYSQLUSER -p$MYSQLPWD -e "delete from unary.$i where taskid='$j'" 2>/dev/null|awk 'NR>1'
|
|
done
|
|
done
|
|
mysql -u$MYSQLUSER -p$MYSQLPWD -e "delete from unary.tbl_report_alarm where level=3" 2>/dev/null|awk 'NR>1'
|
|
|
|
##############################
|
|
exec 1>&11 11>&-
|
|
exec 2>&12 12>&-
|
|
echo success
|
|
exit 0
|