OS: Linux Advanced Server 2.1
  DB: Oracle 8.1.7.0  大致思路:
    1. 关数据前先清掉无用的SESSION(这段脚本我写好了)
        
    2. 正常关闭数据库(SHUTDOWN NORMAL)
    3. 如果数据库不能正常关闭,从日志文件尾部寻找特征串
      "ALTER DATABASE CLOSE NORMAL"
      如果发现存在,则进行冷备份,否则不进行操作.   各位高手帮我看看,或者提供一个好的Solution.   附件:
    
    1.Killsession.sql
 
create or replace procedure KillSess 
isi_sid number; 
i_serial number; cursor cur_sess is 
      select sid, serial# 
       from v$session 
       where status = 'INACTIVE' 
       and type!= 'BACKGROUD'; 
Begin 
    open cur_sess; 
    loop 
        fetch cur_sess into i_sid,i_serial; 
        if cur_sess%notfound then 
           exit; 
        end if; 
     
        execute immediate 'alter system kill session ''' || i_sid ||','
        ||  i_serial ||'''';
    end loop; 
     close cur_sess;
End; 
/ 2.  autoshut.sql
-- This script file is an assistant file with CronTab
-- function: kill all non-background and inactive processesexecute killsess;
alter system checkpoint;
shutdown normal;
exit;
 
3. nightbak.sh
#  crontab:  
#  30 21 * * 1-5 sh /vld/dbbackup/nightbak.sh  
 cat /dbbackup/cronjobs/syspw |sqlplus sys @autoshut.sql
  
tail alert_ora817.log |grep 'Completed: ALTER DATABASE CLOSE NORMAL' 1>temp
if test -s temp;
then
# echo 'found'
   cd /oracle/ora817/oradata
   cp *.dbf ./backup
   cp *.ctl /backup/ctlfile
else
# echo 'not found'
fi