pfmCLI Login Success
Package: 01-NRATER01
Service Name Process Name SGDI TYPE PSID Q-CNT Rate B-CNT STAT Q-ID
============================================================================================
20.MONTHLY 20.73.CI 000002 CI 000224 0 0.0 0 0 000224
10.RATING 10.10.Login 000001 Login 000011 0 0.0 0 0 000011
#!/bin/sh
export ORA_USER=ORABRM
export ORA_PWD=Ps_orabrm001
export ORACLE_SID=PSBSS
DB_PROC(){
sqlplus -s ${ORA_USER}/${ORA_PWD}@${ORACLE_SID} << EOF
set termout off
set feedback off
set heading off
set verify off
set echo off
set linesize 80
set pagesize 0
insert into ZCF_BAT_MONLOG
(SYSTEM
,PROGRAM_ID
,MODULE
,LOG_FILE_PATH
,CREATE_DTM
,LOG_FILE_NM
,ID
,PROCESS_YN
)
select 'NTBS',
'nRater',
'pb',
'./SDSN/nrater/log/check_log',
sysdate,
(SELECT 'nRater_' || TO_CHAR(SYSDATE,'YYYYMMDD') || '.log' from DUAL),
((SELECT (NVL(MAX(ID),0)) from ZCF_BAT_MONLOG)+1) AS ID,
'N'
FROM DUAL;
commit;
exit
EOF
}
CNT=0
while [ 1 ]
do
vRundate = `date+'%H'`
vSettleTense = `date+'%Y%m%d%H%M%S'`
echo $vSettleTense
sleep 2h;
if [ $vRundate -lt 07 ]
then
echo "continue"
continue
fi
MAX=0
NUMS=0
TESTDOING=0.0
JOB_LOG_FILE=/SDSN/nrater/log/check_log/nRater_`date+%y%m%d`.log
pfmCLI -i $PKGID -q > ${JOB_LOG_FILE} & //执行结果如上所示
sleep 2
cat ${JOB_LOG_FILE} | while read line //使用了管道符号,会形成子shell
do
NUMS = `expr $NUMS+1`
if [ $NUMS -lt 5 ]
then
continue //第6行开始才是数据,需要跳过前5行
fi
array = (${line///' '/})
wait=${array[5]}
doing=${array[6]}
if [[ ! -z $wait ]];then
if [[ $wait -gt $MAX ]];then
CNT=`expr $CNT + 1`
echo ${CNT}
DB_PROC
exit 1 //因为前面使用了管道符号,所以这里只能退出子shell,不能直接退出父shell
fi
fi
if [[ ! -z $doing ]];then
if [[ $dong -gt $TESTDOING ]];then
CNT=`expr $CNT + 1`
echo ${CNT}
DB_PROC
exit 1
fi
fi
done
if [ $? -eq 1 ] //取得上个exit的退出值,再次exit就可以退出父shell了 这里不能直接取CNT的值,因为CNT的值在子shell中,父shell是取不到的
then
exit 1
fi
done
cat ${JOB_LOG_FILE} | while read line
do
XXX
done
因为使用了管道符号所以会形成子shell,子shell中修改了父shell值,在父shell中是取不到修改后的值的,并且exti不能直接退出父shell
解决办法如下
while read line
do
XXX
done < ${JOB_LOG_FILE}