shell脚本出错:进程无法被杀死

时间:2014-03-25 22:20:10

标签: bash shell unix kill-process

以下是我的脚本,当我尝试杀死进程时,我收到错误。该错误表明该进程不存在:

select case when max(LAST_MODIFIED_DATE) > to_date('$TO_EXTRACT_VALUE', 'YYYY-MM-DD HH24:MI:SS')  then 0
else 1
    end
    from $ORACLE_TABLE;" > $SQL_TMP_FILE

    PID=$(ps -ef | grep sqlplus | head -1 | awk '{print $2}')
    print $PID
    sleep 10  > $SQL_TMP_FILE
    kill -9 $PID > $SQL_TMP_FILE

     #echo "FILE_ID: $FILE_ID"
    check_result=$(sqlplus -S  ${ORA_USERNAME}/${ORA_PASSWORD}@$TNS_NAME < $SQL_TMP_FILE)

以下是调试输出:

select case when max(LAST_MODIFIED_DATE) > to_date('2014-03-25 00:00:00', 'YYYY-MM-DD HH24:MI:SS')  then 0
    else 1
        end
        from SHIPPING_TRANSACTION;
+ 1> /dw/etl/home/dev/tmp/extract/dw_da/check_shplx_stby_sync.dw_shpmt.ssa_shpmt_trans_fact_shpmt_trans.tmpfile
+ + ps -ef
+ grep sqlplus
+ head -1
+ awk {print $2}
PID=2303
+ print 2303
2303
+ sleep 10
+ 1> /dw/etl/home/dev/tmp/extract/dw_da/check_shplx_stby_sync.dw_shpmt.ssa_shpmt_trans_fact_shpmt_trans.tmpfile
+ kill -9 2303
+ 1> /dw/etl/home/dev/tmp/extract/dw_da/check_shplx_stby_sync.dw_shpmt.ssa_shpmt_trans_fact_shpmt_trans.tmpfile
kill: 2303: no such process

有人可以帮助我吗

1 个答案:

答案 0 :(得分:0)

您应该使用grep sqlplus | grep -v greppgrep sqlplus代替grep sqlplus 也许2303是grep命令的PID,而不是sqlplus。