When am running the below script.
{code}
Script :
#!/bin/sh
ORACLE_BASE=/medt/appl/oracle export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/102 export ORACLE_HOME
ORACLE_SID=meds1 export ORACLE_SID
PATH=/usr/ccs/bin:$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/medt/oracrs/product/102/bin
export PATH
DATE_SUFFIX=`date +%b%d.%H%M`
tmpdir=/medt/work/scripts/jobs/logs
tmpfile="$tmpdir/SESSmeds1$DATE_SUFFIX.log"
sqlplus medsbkp/medsbkp@meds1i as sysdba <<EOF
set timing on
spool $tmpfile
select p.spid from v\$process p,v\$session s where s.paddr=p.addr and s.status='SNIPED' and s.type!='BACKGROUND';
spool off
exit
for x in `cat $tmpfile | grep "^[0123456789]"`
do
kill -9 $x
done
exit
EOF
{code}
It returns the value from sql, but it doesn't kill the session as expected
as you can see below
tabsdb01
raccbs:/medt/work/scripts/jobs$ sh killsnipsess.sql
cat: cannot open /medt/work/scripts/jobs/logs/SESSTABS1Dec26.1419.log
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Dec 26 14:19:18 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> SQL> SQL>
SPID
------------
1357
Elapsed: 00:00:00.01
SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
This file /medt/work/scripts/jobs/logs/SESSTABS1Dec26.1419.log is created and the output of the script is
SQL> select p.spid from v$process p,v$session s where s.paddr=p.addr and s.status='SNIPED' and s.type!='BACKGROUND';
SPID
------------
1357
Elapsed: 00:00:00.01
SQL> spool off
Any idea what am missing ?
Kai