Linux 自动调度问题

crontab -l 如下:
00 23 * * * /home/pmi/shell/I_SHL_SHE_BASE.sh>/home/pmi/log/cron_base.log 2 >&1
50 23 * * * /home/pmi/shell/I_SHL_SHE_MID.sh>/home/pmi/log/cron_mid.log 2 >&1

配置文件env.cfg:

pmi_dbuser=pmi78_user_test
pmi_dbpwd=pmi78_user_test
pmi_dbname=pmi
pmi_bworkdate=20100108
pmi_mworkdate=20100108
pmi_bstatus=0
pmi_mstatus=0
pmi_logpath=/home/pmi/log


如下是I_SHL_SHE_BASE.sh中开始的一段脚本

###########################步骤1:初始化env.cfg文件及Job##############################

step1=`sh $shellpath/I_SHL_INIT.sh>step1.log`
st1=`grep 'flag' step1.log |awk -F"=" '{print $2}'`
if [ "$st1" -eq "0" ]
then
    echo "初始化env.cfg文件成功!"
    rm step1.log
else
    echo "初始化env.cfg文件失败!"
    rm step1.log
    exit -1;
fi

如下是I_SHL_INIT.sh:
#!/bin/bash
#********************************************************************************
#       Function:I_SHL_INIT.sh
#       Inputs:
#       Author:  XX
#       Date:    2009-12-20
#       History:
#********************************************************************************
shellpath=/home/pmi/shell

logpath=`grep 'pmi_logpath' $shellpath/env.cfg |awk -F"=" '{print $2}'`
dbuser=`grep 'pmi_dbuser' $shellpath/env.cfg |awk -F"=" '{print $2}'`
dbpwd=`grep 'pmi_dbpwd'  $shellpath/env.cfg |awk -F"=" '{print $2}'`
dbname=`grep 'pmi_dbname' $shellpath/env.cfg |awk -F"=" '{print $2}'`
logname="$logpath/init.log"

sqlplus -S ${dbuser}/${dbpwd}@${dbname} <<!>$logname
    select pmi_key||'='||pmi_value from pmi_bb_dd_ddcsb;
    show sqlcode;
    quit;
!

#结果处理

sqlcode=`grep 'sqlcode' $logname |awk -F" " '{print $2}'`
if [ -f "$logname"  -a  $sqlcode -eq "0" ]  
then
    pmi_dbuser=`grep 'dbuser' $logname |awk -F"=" '{print $2}'`
    pmi_dbpwd=`grep 'dbpwd' $logname |awk -F"=" '{print $2}'`
    pmi_dbname=`grep 'dbname' $logname |awk -F"=" '{print $2}'`
    pmi_bworkdate=`grep 'bworkdate' $logname |awk -F"=" '{print $2}'`
    pmi_mworkdate=`grep 'mworkdate' $logname |awk -F"=" '{print $2}'`
    pmi_bstatus=`grep 'bstatus' $logname |awk -F"=" '{print $2}'`
    pmi_mstatus=`grep 'mstatus' $logname |awk -F"=" '{print $2}'`
    pmi_logpath=`grep 'logpath' $logname |awk -F"=" '{print $2}'`
    rm $shellpath/env.cfg
    echo "pmi_dbuser=$pmi_dbuser">$shellpath/env.cfg
    echo "pmi_dbpwd=$pmi_dbpwd">>$shellpath/env.cfg
    echo "pmi_dbname=$pmi_dbname">>$shellpath/env.cfg
    echo "pmi_bworkdate=$pmi_bworkdate">>$shellpath/env.cfg
    echo "pmi_mworkdate=$pmi_mworkdate">>$shellpath/env.cfg
    echo "pmi_bstatus=$pmi_bstatus">>$shellpath/env.cfg  
    echo "pmi_mstatus=$pmi_mstatus">>$shellpath/env.cfg
    echo "pmi_logpath=$pmi_logpath">>$shellpath/env.cfg
    rm $logname
    echo "flag=0"
    exit 0;
else
#  rm $logname;
    echo "flag=-1"
    exit -1;
fi
问题是每次自动调度我都在日志文件中看到:初始化env.cfg文件失败。  仔细检查了一下文件中的数据库、用户名、密码、日志路径都没错。困扰了很久一直找不到原因!

你可能感兴趣的:(linux,脚本,F#,bash)